[clang] [NFC][Clang] Use StringRef instead of string in ClangDiagnosticEmitter (PR #115959)

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 13 09:43:12 PST 2024


================
@@ -158,21 +159,19 @@ static void groupDiagnostics(ArrayRef<const Record *> Diags,
       continue;
     assert(R->getValueAsDef("Class")->getName() != "CLASS_NOTE" &&
            "Note can't be in a DiagGroup");
-    std::string GroupName =
-        std::string(DI->getDef()->getValueAsString("GroupName"));
+    StringRef GroupName = DI->getDef()->getValueAsString("GroupName");
     DiagsInGroup[GroupName].DiagsInGroup.push_back(R);
   }
 
   // Add all DiagGroup's to the DiagsInGroup list to make sure we pick up empty
   // groups (these are warnings that GCC supports that clang never produces).
   for (const Record *Group : DiagGroups) {
-    GroupInfo &GI =
-        DiagsInGroup[std::string(Group->getValueAsString("GroupName"))];
+    GroupInfo &GI = DiagsInGroup[Group->getValueAsString("GroupName")];
     GI.GroupName = Group->getName();
     GI.Defs.push_back(Group);
 
     for (const Record *SubGroup : Group->getValueAsListOfDefs("SubGroups"))
-      GI.SubGroups.push_back(SubGroup->getValueAsString("GroupName").str());
+      GI.SubGroups.push_back(SubGroup->getValueAsString("GroupName"));
----------------
kazutakahirata wrote:

Thanks for the pointer and explanation!

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


More information about the cfe-commits mailing list