[clang] [NFC][Clang] Use StringRef instead of string in ClangDiagnosticEmitter (PR #115959)
Rahul Joshi via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 13 07:04:00 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"));
----------------
jurahul wrote:
Here's where the strings in the SubGroups vector originate from. As with most of my such changes, the strings are ultimately a part of the TableGen Records, which are ultimately backed by RecordKeeperImpl::StringInitStringPool. So the assumption is that the `RecordKeeper` (which is TableGen's IR) outlives the emitter backend invocation, which is true.
https://github.com/llvm/llvm-project/pull/115959
More information about the cfe-commits
mailing list