JDevlieghere created this revision.
JDevlieghere added a reviewer: LLDB.
JDevlieghere added a project: LLDB.
Herald added a subscriber: abidh.
I want to remove the RegularExpression class in Utility and replace it with
llvm::Regex.
This is something I'd do incrementally on the side when I have some spare
minutes. This patch is to make sure everybody is on board and show what the
interface looks like.
Repository:
rLLDB LLDB
https://reviews.llvm.org/D66174
Files:
lldb/source/Host/common/Socket.cpp
lldb/source/Utility/FileSpec.cpp
Index: lldb/source/Utility/FileSpec.cpp
===================================================================
--- lldb/source/Utility/FileSpec.cpp
+++ lldb/source/Utility/FileSpec.cpp
@@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
#include "lldb/Utility/FileSpec.h"
-#include "lldb/Utility/RegularExpression.h"
#include "lldb/Utility/Stream.h"
#include "llvm/ADT/SmallString.h"
@@ -18,6 +17,7 @@
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Program.h"
+#include "llvm/Support/Regex.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
@@ -487,12 +487,12 @@
if (!extension)
return false;
- static RegularExpression g_source_file_regex(llvm::StringRef(
+ static llvm::Regex g_source_file_regex(
"^.([cC]|[mM]|[mM][mM]|[cC][pP][pP]|[cC]\\+\\+|[cC][xX][xX]|[cC][cC]|["
"cC][pP]|[sS]|[aA][sS][mM]|[fF]|[fF]77|[fF]90|[fF]95|[fF]03|[fF][oO]["
"rR]|[fF][tT][nN]|[fF][pP][pP]|[aA][dD][aA]|[aA][dD][bB]|[aA][dD][sS])"
- "$"));
- return g_source_file_regex.Execute(extension.GetStringRef());
+ "$");
+ return g_source_file_regex.match(extension.GetStringRef());
}
bool FileSpec::IsRelative() const {
Index: lldb/source/Host/common/Socket.cpp
===================================================================
--- lldb/source/Host/common/Socket.cpp
+++ lldb/source/Host/common/Socket.cpp
@@ -15,11 +15,11 @@
#include "lldb/Host/common/TCPSocket.h"
#include "lldb/Host/common/UDPSocket.h"
#include "lldb/Utility/Log.h"
-#include "lldb/Utility/RegularExpression.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Errno.h"
#include "llvm/Support/Error.h"
+#include "llvm/Support/Regex.h"
#include "llvm/Support/WindowsError.h"
#ifndef LLDB_DISABLE_POSIX
@@ -280,12 +280,12 @@
bool Socket::DecodeHostAndPort(llvm::StringRef host_and_port,
std::string &host_str, std::string &port_str,
int32_t &port, Status *error_ptr) {
- static RegularExpression g_regex(
- llvm::StringRef("([^:]+|\\[[0-9a-fA-F:]+.*\\]):([0-9]+)"));
- RegularExpression::Match regex_match(2);
- if (g_regex.Execute(host_and_port, ®ex_match)) {
- if (regex_match.GetMatchAtIndex(host_and_port, 1, host_str) &&
- regex_match.GetMatchAtIndex(host_and_port, 2, port_str)) {
+ static llvm::Regex g_regex("([^:]+|\\[[0-9a-fA-F:]+.*\\]):([0-9]+)");
+ llvm::SmallVector<llvm::StringRef, 3> matches;
+ if (g_regex.match(host_and_port, &matches)) {
+ if (matches.size() == 3) {
+ host_str = matches[1].str();
+ port_str = matches[2].str();
// IPv6 addresses are wrapped in [] when specified with ports
if (host_str.front() == '[' && host_str.back() == ']')
host_str = host_str.substr(1, host_str.size() - 2);
Index: lldb/source/Utility/FileSpec.cpp
===================================================================
--- lldb/source/Utility/FileSpec.cpp
+++ lldb/source/Utility/FileSpec.cpp
@@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
#include "lldb/Utility/FileSpec.h"
-#include "lldb/Utility/RegularExpression.h"
#include "lldb/Utility/Stream.h"
#include "llvm/ADT/SmallString.h"
@@ -18,6 +17,7 @@
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Program.h"
+#include "llvm/Support/Regex.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
@@ -487,12 +487,12 @@
if (!extension)
return false;
- static RegularExpression g_source_file_regex(llvm::StringRef(
+ static llvm::Regex g_source_file_regex(
"^.([cC]|[mM]|[mM][mM]|[cC][pP][pP]|[cC]\\+\\+|[cC][xX][xX]|[cC][cC]|["
"cC][pP]|[sS]|[aA][sS][mM]|[fF]|[fF]77|[fF]90|[fF]95|[fF]03|[fF][oO]["
"rR]|[fF][tT][nN]|[fF][pP][pP]|[aA][dD][aA]|[aA][dD][bB]|[aA][dD][sS])"
- "$"));
- return g_source_file_regex.Execute(extension.GetStringRef());
+ "$");
+ return g_source_file_regex.match(extension.GetStringRef());
}
bool FileSpec::IsRelative() const {
Index: lldb/source/Host/common/Socket.cpp
===================================================================
--- lldb/source/Host/common/Socket.cpp
+++ lldb/source/Host/common/Socket.cpp
@@ -15,11 +15,11 @@
#include "lldb/Host/common/TCPSocket.h"
#include "lldb/Host/common/UDPSocket.h"
#include "lldb/Utility/Log.h"
-#include "lldb/Utility/RegularExpression.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Errno.h"
#include "llvm/Support/Error.h"
+#include "llvm/Support/Regex.h"
#include "llvm/Support/WindowsError.h"
#ifndef LLDB_DISABLE_POSIX
@@ -280,12 +280,12 @@
bool Socket::DecodeHostAndPort(llvm::StringRef host_and_port,
std::string &host_str, std::string &port_str,
int32_t &port, Status *error_ptr) {
- static RegularExpression g_regex(
- llvm::StringRef("([^:]+|\\[[0-9a-fA-F:]+.*\\]):([0-9]+)"));
- RegularExpression::Match regex_match(2);
- if (g_regex.Execute(host_and_port, ®ex_match)) {
- if (regex_match.GetMatchAtIndex(host_and_port, 1, host_str) &&
- regex_match.GetMatchAtIndex(host_and_port, 2, port_str)) {
+ static llvm::Regex g_regex("([^:]+|\\[[0-9a-fA-F:]+.*\\]):([0-9]+)");
+ llvm::SmallVector<llvm::StringRef, 3> matches;
+ if (g_regex.match(host_and_port, &matches)) {
+ if (matches.size() == 3) {
+ host_str = matches[1].str();
+ port_str = matches[2].str();
// IPv6 addresses are wrapped in [] when specified with ports
if (host_str.front() == '[' && host_str.back() == ']')
host_str = host_str.substr(1, host_str.size() - 2);
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits