diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp @@ -464,6 +464,17 @@ if (!m_set.function_methods.Find( name, DIERefCallback(callback, name.GetStringRef()))) return; + // With -gsimple-template-names, the die name may not contain template + // parameters. Try stripping the template parameters and try again. + const llvm::StringRef name_ref = name.AsCString(); + auto it = name_ref.find('<'); + if (it != llvm::StringRef::npos) { + const llvm::StringRef name_no_template_params = name_ref.slice(0, it); + if (!m_set.function_methods.Find( + ConstString(name_no_template_params), + DIERefCallback(callback, name_no_template_params))) + return; + } } if (name_type_mask & eFunctionNameTypeSelector && diff --git a/lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py b/lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py --- a/lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py +++ b/lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py @@ -12,7 +12,16 @@ @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764") def test(self): - self.build() + self.do_test(dict()) + + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764") + @skipIf(compiler=no_match("clang")) + @skipIf(compiler_version=["<", "15.0"]) + def test_simple_template_names(self): + self.do_test(dict(CFLAGS_EXTRAS="-gsimple-template-names")) + + def do_test(self, debug_flags): + self.build(dictionary=debug_flags) self.breakpoint_id_tests() def verify_breakpoint_locations(self, target, bp_dict): @@ -57,7 +66,11 @@ # Template cases {'name': 'func', 'loc_names': []}, + {'name': 'Foo::func', 'loc_names': []}, + {'name': 'ns::Foo::func', 'loc_names': []}, {'name': 'func', 'loc_names': ['auto ns::Foo::func()']}, + {'name': 'Foo::func', 'loc_names': ['auto ns::Foo::func()']}, + {'name': 'ns::Foo::func', 'loc_names': ['auto ns::Foo::func()']}, {'name': 'func', 'loc_names': ['auto ns::Foo::func()', 'auto ns::Foo::func>()']},