Skip to content

Commit 52e7c69

Browse files
authored
[Clang][TableGen] Change ClangDiagnosticEmitter to use const Record * (#110585)
This is a part of effort to have better const correctness in TableGen backends: https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
1 parent 017c2ab commit 52e7c69

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

clang/utils/TableGen/ClangDiagnosticsEmitter.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ class DiagGroupParentMap {
4747
ArrayRef<const Record *> DiagGroups =
4848
Records.getAllDerivedDefinitions("DiagGroup");
4949
for (unsigned i = 0, e = DiagGroups.size(); i != e; ++i) {
50-
std::vector<Record*> SubGroups =
51-
DiagGroups[i]->getValueAsListOfDefs("SubGroups");
50+
std::vector<const Record *> SubGroups =
51+
DiagGroups[i]->getValueAsListOfConstDefs("SubGroups");
5252
for (unsigned j = 0, e = SubGroups.size(); j != e; ++j)
5353
Mapping[SubGroups[j]].push_back(DiagGroups[i]);
5454
}
@@ -180,10 +180,8 @@ static void groupDiagnostics(ArrayRef<const Record *> Diags,
180180
GI.GroupName = Group->getName();
181181
GI.Defs.push_back(Group);
182182

183-
std::vector<Record*> SubGroups = Group->getValueAsListOfDefs("SubGroups");
184-
for (unsigned j = 0, e = SubGroups.size(); j != e; ++j)
185-
GI.SubGroups.push_back(
186-
std::string(SubGroups[j]->getValueAsString("GroupName")));
183+
for (const Record *SubGroup : Group->getValueAsListOfDefs("SubGroups"))
184+
GI.SubGroups.push_back(SubGroup->getValueAsString("GroupName").str());
187185
}
188186

189187
// Assign unique ID numbers to the groups.

0 commit comments

Comments
 (0)