[clang] 1d39b4f - [Clang][TableGen] Change SACheckersEmitter to use const Record * (#110596)

via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 1 10:46:36 PDT 2024


Author: Rahul Joshi
Date: 2024-10-01T10:46:32-07:00
New Revision: 1d39b4f7175d8d75af6e3711dc7fa88a13df5af1

URL: https://github.com/llvm/llvm-project/commit/1d39b4f7175d8d75af6e3711dc7fa88a13df5af1
DIFF: https://github.com/llvm/llvm-project/commit/1d39b4f7175d8d75af6e3711dc7fa88a13df5af1.diff

LOG: [Clang][TableGen] Change SACheckersEmitter to use const Record * (#110596)

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

Added: 
    

Modified: 
    clang/utils/TableGen/ClangSACheckersEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/clang/utils/TableGen/ClangSACheckersEmitter.cpp b/clang/utils/TableGen/ClangSACheckersEmitter.cpp
index 998c5ed2079d71..bebdcac3212613 100644
--- a/clang/utils/TableGen/ClangSACheckersEmitter.cpp
+++ b/clang/utils/TableGen/ClangSACheckersEmitter.cpp
@@ -229,9 +229,8 @@ void clang::EmitClangSACheckers(const RecordKeeper &Records, raw_ostream &OS) {
     if (Package->isValueUnset("PackageOptions"))
       continue;
 
-    std::vector<Record *> PackageOptions = Package
-                                       ->getValueAsListOfDefs("PackageOptions");
-    for (Record *PackageOpt : PackageOptions) {
+    for (const Record *PackageOpt :
+         Package->getValueAsListOfDefs("PackageOptions")) {
       OS << "PACKAGE_OPTION(";
       printOption(OS, getPackageFullName(Package), *PackageOpt);
       OS << ")\n";
@@ -325,13 +324,11 @@ void clang::EmitClangSACheckers(const RecordKeeper &Records, raw_ostream &OS) {
   OS << "\n"
         "#ifdef GET_CHECKER_OPTIONS\n";
   for (const Record *Checker : checkers) {
-
     if (Checker->isValueUnset("CheckerOptions"))
       continue;
 
-    std::vector<Record *> CheckerOptions = Checker
-                                       ->getValueAsListOfDefs("CheckerOptions");
-    for (Record *CheckerOpt : CheckerOptions) {
+    for (const Record *CheckerOpt :
+         Checker->getValueAsListOfDefs("CheckerOptions")) {
       OS << "CHECKER_OPTION(";
       printOption(OS, getCheckerFullName(Checker), *CheckerOpt);
       OS << ")\n";


        


More information about the cfe-commits mailing list