168 lines
6.8 KiB
Diff
168 lines
6.8 KiB
Diff
From 96868d29541c046cf85ed0423cfee4ebf64b341a Mon Sep 17 00:00:00 2001
|
|
From: Pavel Labath <labath@google.com>
|
|
Date: Mon, 5 Sep 2016 15:15:12 +0000
|
|
Subject: [PATCH] Replace uses of MIUtilParse::CRegexParser with llvm::Regex
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Summary:
|
|
Replace uses of the local MIUtilParse::CRegexParser class with the LLVM support class llvm::Regex. This reduces duplication of code, and makes it possible to remove the MIUtilParse::CRegexParser class that requires LLVM internal implementation headers.
|
|
|
|
Bug: https://llvm.org/bugs/show_bug.cgi?id=29138
|
|
|
|
Reviewers: dawn, abidh, ki.stfu
|
|
|
|
Subscribers: labath, ki.stfu, lldb-commits
|
|
|
|
Differential Revision: https://reviews.llvm.org/D23882
|
|
Author: Michał Górny <mgorny@gentoo.org>
|
|
|
|
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@280662 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
---
|
|
tools/lldb-mi/MICmdCmdData.cpp | 28 +++++++++++++++-------------
|
|
tools/lldb-mi/MICmdCmdSymbol.cpp | 38 ++++++++++++++++++++------------------
|
|
2 files changed, 35 insertions(+), 31 deletions(-)
|
|
|
|
diff --git a/tools/lldb-mi/MICmdCmdData.cpp b/tools/lldb-mi/MICmdCmdData.cpp
|
|
index a46fb55..7f4c2e8 100644
|
|
--- a/tools/lldb-mi/MICmdCmdData.cpp
|
|
+++ b/tools/lldb-mi/MICmdCmdData.cpp
|
|
@@ -25,6 +25,9 @@
|
|
#include "lldb/API/SBInstruction.h"
|
|
#include "lldb/API/SBInstructionList.h"
|
|
#include "lldb/API/SBStream.h"
|
|
+#include "llvm/ADT/SmallVector.h"
|
|
+#include "llvm/ADT/StringRef.h"
|
|
+#include "llvm/Support/Regex.h"
|
|
|
|
// In-house headers:
|
|
#include "MICmdCmdData.h"
|
|
@@ -42,7 +45,6 @@
|
|
#include "MICmdArgValConsume.h"
|
|
#include "MICmnLLDBDebugSessionInfoVarObj.h"
|
|
#include "MICmnLLDBUtilSBValue.h"
|
|
-#include "MIUtilParse.h"
|
|
|
|
//++ ------------------------------------------------------------------------------------
|
|
// Details: CMICmdCmdDataEvaluateExpression constructor.
|
|
@@ -1651,24 +1653,24 @@ ParseLLDBLineEntry(const char *input, CMIUtilString &start, CMIUtilString &end,
|
|
// is remains is assumed to be the filename.
|
|
|
|
// Match LineEntry using regex.
|
|
- static MIUtilParse::CRegexParser g_lineentry_nocol_regex(
|
|
- "^ *LineEntry: \\[(0x[0-9a-fA-F]+)-(0x[0-9a-fA-F]+)\\): (.+):([0-9]+)$");
|
|
- static MIUtilParse::CRegexParser g_lineentry_col_regex(
|
|
- "^ *LineEntry: \\[(0x[0-9a-fA-F]+)-(0x[0-9a-fA-F]+)\\): (.+):([0-9]+):[0-9]+$");
|
|
- // ^1=start ^2=end ^3=f ^4=line ^5=:col(opt)
|
|
+ static llvm::Regex g_lineentry_nocol_regex(
|
|
+ llvm::StringRef("^ *LineEntry: \\[(0x[0-9a-fA-F]+)-(0x[0-9a-fA-F]+)\\): (.+):([0-9]+)$"));
|
|
+ static llvm::Regex g_lineentry_col_regex(
|
|
+ llvm::StringRef("^ *LineEntry: \\[(0x[0-9a-fA-F]+)-(0x[0-9a-fA-F]+)\\): (.+):([0-9]+):[0-9]+$"));
|
|
+ // ^1=start ^2=end ^3=f ^4=line ^5=:col(opt)
|
|
|
|
- MIUtilParse::CRegexParser::Match match(6);
|
|
+ llvm::SmallVector<llvm::StringRef, 6> match;
|
|
|
|
// First try matching the LineEntry with the column,
|
|
// then try without the column.
|
|
- const bool ok = g_lineentry_col_regex.Execute(input, match) ||
|
|
- g_lineentry_nocol_regex.Execute(input, match);
|
|
+ const bool ok = g_lineentry_col_regex.match(input, &match) ||
|
|
+ g_lineentry_nocol_regex.match(input, &match);
|
|
if (ok)
|
|
{
|
|
- start = match.GetMatchAtIndex(1);
|
|
- end = match.GetMatchAtIndex(2);
|
|
- file = match.GetMatchAtIndex(3);
|
|
- line = match.GetMatchAtIndex(4);
|
|
+ start = match[1];
|
|
+ end = match[2];
|
|
+ file = match[3];
|
|
+ line = match[4];
|
|
}
|
|
return ok;
|
|
}
|
|
diff --git a/tools/lldb-mi/MICmdCmdSymbol.cpp b/tools/lldb-mi/MICmdCmdSymbol.cpp
|
|
index abaa392..b2519af 100644
|
|
--- a/tools/lldb-mi/MICmdCmdSymbol.cpp
|
|
+++ b/tools/lldb-mi/MICmdCmdSymbol.cpp
|
|
@@ -11,6 +11,9 @@
|
|
|
|
// Third Party Headers:
|
|
#include "lldb/API/SBCommandInterpreter.h"
|
|
+#include "llvm/ADT/SmallVector.h"
|
|
+#include "llvm/ADT/StringRef.h"
|
|
+#include "llvm/Support/Regex.h"
|
|
|
|
// In-house headers:
|
|
#include "MICmdArgValFile.h"
|
|
@@ -19,7 +22,6 @@
|
|
#include "MICmnMIResultRecord.h"
|
|
#include "MICmnMIValueList.h"
|
|
#include "MICmnMIValueTuple.h"
|
|
-#include "MIUtilParse.h"
|
|
|
|
//++ ------------------------------------------------------------------------------------
|
|
// Details: CMICmdCmdSymbolListLines constructor.
|
|
@@ -105,15 +107,15 @@ static bool
|
|
ParseLLDBLineAddressHeader(const char *input, CMIUtilString &file)
|
|
{
|
|
// Match LineEntry using regex.
|
|
- static MIUtilParse::CRegexParser g_lineentry_header_regex(
|
|
- "^ *Lines found for file (.+) in compilation unit (.+) in `(.+)$");
|
|
- // ^1=file ^2=cu ^3=module
|
|
+ static llvm::Regex g_lineentry_header_regex(
|
|
+ llvm::StringRef("^ *Lines found for file (.+) in compilation unit (.+) in `(.+)$"));
|
|
+ // ^1=file ^2=cu ^3=module
|
|
|
|
- MIUtilParse::CRegexParser::Match match(4);
|
|
+ llvm::SmallVector<llvm::StringRef, 4> match;
|
|
|
|
- const bool ok = g_lineentry_header_regex.Execute(input, match);
|
|
+ const bool ok = g_lineentry_header_regex.match(input, &match);
|
|
if (ok)
|
|
- file = match.GetMatchAtIndex(1);
|
|
+ file = match[1];
|
|
return ok;
|
|
}
|
|
|
|
@@ -141,23 +143,23 @@ ParseLLDBLineAddressEntry(const char *input, CMIUtilString &addr,
|
|
// is remains is assumed to be the filename.
|
|
|
|
// Match LineEntry using regex.
|
|
- static MIUtilParse::CRegexParser g_lineentry_nocol_regex(
|
|
- "^ *\\[(0x[0-9a-fA-F]+)-(0x[0-9a-fA-F]+)\\): (.+):([0-9]+)$");
|
|
- static MIUtilParse::CRegexParser g_lineentry_col_regex(
|
|
- "^ *\\[(0x[0-9a-fA-F]+)-(0x[0-9a-fA-F]+)\\): (.+):([0-9]+):[0-9]+$");
|
|
- // ^1=start ^2=end ^3=f ^4=line ^5=:col(opt)
|
|
+ static llvm::Regex g_lineentry_nocol_regex(
|
|
+ llvm::StringRef("^ *\\[(0x[0-9a-fA-F]+)-(0x[0-9a-fA-F]+)\\): (.+):([0-9]+)$"));
|
|
+ static llvm::Regex g_lineentry_col_regex(
|
|
+ llvm::StringRef("^ *\\[(0x[0-9a-fA-F]+)-(0x[0-9a-fA-F]+)\\): (.+):([0-9]+):[0-9]+$"));
|
|
+ // ^1=start ^2=end ^3=f ^4=line ^5=:col(opt)
|
|
|
|
- MIUtilParse::CRegexParser::Match match(6);
|
|
+ llvm::SmallVector<llvm::StringRef, 6> match;
|
|
|
|
// First try matching the LineEntry with the column,
|
|
// then try without the column.
|
|
- const bool ok = g_lineentry_col_regex.Execute(input, match) ||
|
|
- g_lineentry_nocol_regex.Execute(input, match);
|
|
+ const bool ok = g_lineentry_col_regex.match(input, &match) ||
|
|
+ g_lineentry_nocol_regex.match(input, &match);
|
|
if (ok)
|
|
{
|
|
- addr = match.GetMatchAtIndex(1);
|
|
- file = match.GetMatchAtIndex(3);
|
|
- line = match.GetMatchAtIndex(4);
|
|
+ addr = match[1];
|
|
+ file = match[3];
|
|
+ line = match[4];
|
|
}
|
|
return ok;
|
|
}
|
|
--
|
|
2.5.5
|
|
|