diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp --- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp @@ -9,6 +9,7 @@ #include "CPlusPlusNameParser.h" #include "clang/Basic/IdentifierTable.h" +#include "clang/Basic/TokenKinds.h" #include "llvm/ADT/StringMap.h" #include "llvm/Support/Threading.h" @@ -106,7 +107,7 @@ Bookmark start_position = SetBookmark(); if (expect_return_type) { // Consume return type if it's expected. - if (!ConsumeTypename()) + if (!ConsumeToken(tok::kw_auto) && !ConsumeTypename()) return None; } diff --git a/lldb/test/API/functionalities/step-avoids-regexp/Makefile b/lldb/test/API/functionalities/step-avoids-regexp/Makefile new file mode 100644 --- /dev/null +++ b/lldb/test/API/functionalities/step-avoids-regexp/Makefile @@ -0,0 +1,4 @@ +CXX_SOURCES := main.cpp +CXXFLAGS_EXTRAS := -std=c++20 + +include Makefile.rules diff --git a/lldb/test/API/functionalities/step-avoids-regexp/TestStepAvoidsRegexp.py b/lldb/test/API/functionalities/step-avoids-regexp/TestStepAvoidsRegexp.py new file mode 100644 --- /dev/null +++ b/lldb/test/API/functionalities/step-avoids-regexp/TestStepAvoidsRegexp.py @@ -0,0 +1,47 @@ +""" +Test thread step-in ignores frames according to the "Avoid regexp" option. +""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class StepAvoidsRegexTestCase(TestBase): + def hit_correct_function(self, pattern): + name = self.thread.frames[0].GetFunctionName() + self.assertTrue( + pattern in name, "Got to '%s' not the expected function '%s'." % + (name, pattern)) + + def setUp(self): + TestBase.setUp(self) + self.dbg.HandleCommand( + "settings set target.process.thread.step-avoid-regexp ^ignore::") + + def test_step_avoid_regex(self): + """Tests stepping into a function which matches the avoid regex""" + self.build() + (_, _, self.thread, _) = lldbutil.run_to_source_breakpoint(self, "main", lldb.SBFileSpec('main.cpp')) + + # Try to step into ignore::auto_ret + self.thread.StepInto() + self.hit_correct_function("main") + + # Try to step into ignore::with_tag + self.thread.StepInto() + self.hit_correct_function("main") + + # Try to step into ignore::decltype_auto_ret + self.thread.StepInto() + self.hit_correct_function("main") + + @expectedFailureAll(bugnumber="rdar://100645742") + def test_step_avoid_regex_abi_tagged_template(self): + """Tests stepping into an ABI tagged function that matches the avoid regex""" + self.build() + (_, _, self.thread, _) = lldbutil.run_to_source_breakpoint(self, "with_tag_template", lldb.SBFileSpec('main.cpp')) + + # Try to step into ignore::with_tag_template + self.thread.StepInto() + self.hit_correct_function("main") diff --git a/lldb/test/API/functionalities/step-avoids-regexp/main.cpp b/lldb/test/API/functionalities/step-avoids-regexp/main.cpp new file mode 100644 --- /dev/null +++ b/lldb/test/API/functionalities/step-avoids-regexp/main.cpp @@ -0,0 +1,18 @@ +#include + +namespace ignore { +template auto auto_ret(T x) { return 0; } +[[gnu::abi_tag("test")]] int with_tag() { return 0; } +template [[gnu::abi_tag("test")]] int with_tag_template() { + return 0; +} + +template decltype(auto) decltype_auto_ret(T x) { return 0; } +} // namespace ignore + +int main() { + auto v1 = ignore::auto_ret(5); + auto v2 = ignore::with_tag(); + auto v3 = ignore::decltype_auto_ret(5); + auto v4 = ignore::with_tag_template(); +} diff --git a/lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp b/lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp --- a/lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp +++ b/lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp @@ -65,8 +65,10 @@ "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()() " + "const", + "main::{lambda()#1}::operator()() const::{lambda()#1}", "operator()", + "()", "const", "main::{lambda()#1}::operator()() const::{lambda()#1}::operator()"}, // Function pointers @@ -110,8 +112,15 @@ "f, sizeof(B)", "()", "", "f, sizeof(B)"}, {"llvm::Optional::operator*() const volatile &&", - "llvm::Optional", "operator*", "()", "const volatile &&", - "llvm::Optional::operator*"}}; + "llvm::Optional", "operator*", "()", + "const volatile &&", "llvm::Optional::operator*"}, + + // auto return type + {"auto std::test_return_auto() const", "std", + "test_return_auto", "()", "const", "std::test_return_auto"}, + {"decltype(auto) std::test_return_auto(int) const", "std", + "test_return_auto", "(int)", "const", + "std::test_return_auto"}}; for (const auto &test : test_cases) { CPlusPlusLanguage::MethodName method(ConstString(test.input));