From 16c662129082158d80c7176d811d3575d45e9f13 Mon Sep 17 00:00:00 2001 From: Rahul Joshi Date: Tue, 1 Oct 2024 06:52:20 -0700 Subject: [PATCH] [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 --- clang/utils/TableGen/ClangDiagnosticsEmitter.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp index 7a8aa181c7588f..d9bb0630aff5f3 100644 --- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp +++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp @@ -47,8 +47,8 @@ class DiagGroupParentMap { ArrayRef DiagGroups = Records.getAllDerivedDefinitions("DiagGroup"); for (unsigned i = 0, e = DiagGroups.size(); i != e; ++i) { - std::vector SubGroups = - DiagGroups[i]->getValueAsListOfDefs("SubGroups"); + std::vector SubGroups = + DiagGroups[i]->getValueAsListOfConstDefs("SubGroups"); for (unsigned j = 0, e = SubGroups.size(); j != e; ++j) Mapping[SubGroups[j]].push_back(DiagGroups[i]); } @@ -180,10 +180,8 @@ static void groupDiagnostics(ArrayRef Diags, GI.GroupName = Group->getName(); GI.Defs.push_back(Group); - std::vector SubGroups = Group->getValueAsListOfDefs("SubGroups"); - for (unsigned j = 0, e = SubGroups.size(); j != e; ++j) - GI.SubGroups.push_back( - std::string(SubGroups[j]->getValueAsString("GroupName"))); + for (const Record *SubGroup : Group->getValueAsListOfDefs("SubGroups")) + GI.SubGroups.push_back(SubGroup->getValueAsString("GroupName").str()); } // Assign unique ID numbers to the groups.