[llvm] Fix llvm::StripTemplateParameters to not return an empty name. (PR #157553)

Greg Clayton via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 9 11:25:22 PDT 2025


================
@@ -299,4 +299,18 @@ TEST(DWARFDebugNames, UnsupportedForm) {
       Sections,
       FailedWithMessage("unsupported Form for YAML debug_names emitter"));
 }
+
+TEST(DWARFDebugNames, TestStripTemplateParameters) {
+
+  std::optional<StringRef> stripped_name;
+  // Make sure we can extract the name "foo" from the template parameters.
+  stripped_name = StripTemplateParameters("foo<int>");
+  ASSERT_TRUE(stripped_name.has_value());
+  ASSERT_EQ(*stripped_name, StringRef("foo"));
+  // Make sure that we don't get an empty name back when the string starts with
----------------
clayborg wrote:

I reworded the comment to indicate we expect to not get a string back. Previously we were getting an empty string back from this call.

https://github.com/llvm/llvm-project/pull/157553


More information about the llvm-commits mailing list