[clang] [Clang][TableGen] Change ClangDiagnosticEmitter to use const Record * (PR #110585)

via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 30 18:54:10 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Rahul Joshi (jurahul)

<details>
<summary>Changes</summary>

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

---
Full diff: https://github.com/llvm/llvm-project/pull/110585.diff


1 Files Affected:

- (modified) clang/utils/TableGen/ClangDiagnosticsEmitter.cpp (+4-6) 


``````````diff
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<const Record *> DiagGroups =
         Records.getAllDerivedDefinitions("DiagGroup");
     for (unsigned i = 0, e = DiagGroups.size(); i != e; ++i) {
-      std::vector<Record*> SubGroups =
-        DiagGroups[i]->getValueAsListOfDefs("SubGroups");
+      std::vector<const Record *> 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<const Record *> Diags,
     GI.GroupName = Group->getName();
     GI.Defs.push_back(Group);
 
-    std::vector<Record*> 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.

``````````

</details>


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


More information about the cfe-commits mailing list