[Lldb-commits] [lldb] r307944 - Enable parsing C++ names generated by lambda functions.
Jim Ingham via lldb-commits
lldb-commits at lists.llvm.org
Thu Jul 13 12:48:43 PDT 2017
Author: jingham
Date: Thu Jul 13 12:48:43 2017
New Revision: 307944
URL: http://llvm.org/viewvc/llvm-project?rev=307944&view=rev
Log:
Enable parsing C++ names generated by lambda functions.
https://reviews.llvm.org/D34911 from Weng Xuetian.
Modified:
lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h
lldb/trunk/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp?rev=307944&r1=307943&r2=307944&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp Thu Jul 13 12:48:43 2017
@@ -274,6 +274,28 @@ bool CPlusPlusNameParser::ConsumeAnonymo
return true;
}
+bool CPlusPlusNameParser::ConsumeLambda() {
+ Bookmark start_position = SetBookmark();
+ if (!ConsumeToken(tok::l_brace)) {
+ return false;
+ }
+ constexpr llvm::StringLiteral g_lambda("lambda");
+ if (HasMoreTokens() && Peek().is(tok::raw_identifier) &&
+ Peek().getRawIdentifier() == g_lambda) {
+ // Put the matched brace back so we can use ConsumeBrackets
+ TakeBack();
+ } else {
+ return false;
+ }
+
+ if (!ConsumeBrackets(tok::l_brace, tok::r_brace)) {
+ return false;
+ }
+
+ start_position.Remove();
+ return true;
+}
+
bool CPlusPlusNameParser::ConsumeBrackets(tok::TokenKind left,
tok::TokenKind right) {
Bookmark start_position = SetBookmark();
@@ -502,6 +524,15 @@ CPlusPlusNameParser::ParseFullNameImpl()
state = State::AfterTwoColons;
break;
}
+ case tok::l_brace:
+ if (state == State::Beginning || state == State::AfterTwoColons) {
+ if (ConsumeLambda()) {
+ state = State::AfterIdentifier;
+ break;
+ }
+ }
+ continue_parsing = false;
+ break;
case tok::coloncolon: // Type nesting delimiter.
if (state != State::Beginning && state != State::AfterIdentifier &&
state != State::AfterTemplate) {
Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h?rev=307944&r1=307943&r2=307944&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h Thu Jul 13 12:48:43 2017
@@ -143,6 +143,9 @@ private:
// Consumes '(anonymous namespace)'
bool ConsumeAnonymousNamespace();
+ // Consumes '{lambda ...}'
+ bool ConsumeLambda();
+
// Consumes operator declaration like 'operator *' or 'operator delete []'
bool ConsumeOperator();
Modified: lldb/trunk/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp?rev=307944&r1=307943&r2=307944&view=diff
==============================================================================
--- lldb/trunk/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp (original)
+++ lldb/trunk/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp Thu Jul 13 12:48:43 2017
@@ -62,6 +62,11 @@ TEST(CPlusPlusLanguage, MethodNameParsin
"XX::(anonymous namespace)::anon_class", "anon_func", "()", "const",
"XX::(anonymous namespace)::anon_class::anon_func"},
+ // Lambda
+ {"main::{lambda()#1}::operator()() const::{lambda()#1}::operator()() const",
+ "main::{lambda()#1}::operator()() const::{lambda()#1}", "operator()", "()", "const",
+ "main::{lambda()#1}::operator()() const::{lambda()#1}::operator()"},
+
// Function pointers
{"string (*f(vector<int>&&))(float)", "", "f", "(vector<int>&&)", "",
"f"},
More information about the lldb-commits
mailing list