[clang] [clang][TableGen] Change ASTProperties Emitter to use const RecordKeeper (PR #108274)

via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 11 11:58:31 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff e3f936eb755d9ae37019ffcc7f53d71d2d58d188 d5396fdc12a6a24960b42ec9f50556b00e42e08e --extensions cpp,h -- clang/utils/TableGen/ClangASTPropertiesEmitter.cpp clang/utils/TableGen/TableGenBackends.h
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp b/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp
index 7cf437a4a2..a967ecb652 100644
--- a/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp
+++ b/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp
@@ -91,93 +91,94 @@ class ASTPropsEmitter {
 	raw_ostream &Out;
         const RecordKeeper &Records;
         std::map<HasProperties, NodeInfo> NodeInfos;
-  std::vector<PropertyType> AllPropertyTypes;
-  std::map<PropertyType, CasedTypeInfo> CasedTypeInfos;
-
-public:
-  ASTPropsEmitter(const RecordKeeper &records, raw_ostream &out)
-      : Out(out), Records(records) {
-
-    // Find all the properties.
-    for (Property property :
-         records.getAllDerivedDefinitions(PropertyClassName)) {
-      HasProperties node = property.getClass();
-      NodeInfos[node].Properties.push_back(property);
-    }
-
-    // Find all the creation rules.
-    for (CreationRule creationRule :
-           records.getAllDerivedDefinitions(CreationRuleClassName)) {
-      HasProperties node = creationRule.getClass();
-
-      auto &info = NodeInfos[node];
-      if (info.Creator) {
-        PrintFatalError(creationRule.getLoc(),
-                        "multiple creator rules for \"" + node.getName()
-                          + "\"");
-      }
-      info.Creator = creationRule;
-    }
-
-    // Find all the override rules.
-    for (OverrideRule overrideRule :
-           records.getAllDerivedDefinitions(OverrideRuleClassName)) {
-      HasProperties node = overrideRule.getClass();
-
-      auto &info = NodeInfos[node];
-      if (info.Override) {
-        PrintFatalError(overrideRule.getLoc(),
-                        "multiple override rules for \"" + node.getName()
-                          + "\"");
-      }
-      info.Override = overrideRule;
-    }
-
-    // Find all the write helper rules.
-    for (ReadHelperRule helperRule :
-           records.getAllDerivedDefinitions(ReadHelperRuleClassName)) {
-      HasProperties node = helperRule.getClass();
-
-      auto &info = NodeInfos[node];
-      if (info.ReadHelper) {
-        PrintFatalError(helperRule.getLoc(),
-                        "multiple write helper rules for \"" + node.getName()
-                          + "\"");
-      }
-      info.ReadHelper = helperRule;
-    }
-
-    // Find all the concrete property types.
-    for (PropertyType type :
-           records.getAllDerivedDefinitions(PropertyTypeClassName)) {
-      // Ignore generic specializations; they're generally not useful when
-      // emitting basic emitters etc.
-      if (type.isGenericSpecialization()) continue;
-
-      AllPropertyTypes.push_back(type);
-    }
-
-    // Find all the type kind rules.
-    for (TypeKindRule kindRule :
-           records.getAllDerivedDefinitions(TypeKindClassName)) {
-      PropertyType type = kindRule.getParentType();
-      auto &info = CasedTypeInfos[type];
-      if (info.KindRule) {
-        PrintFatalError(kindRule.getLoc(),
-                        "multiple kind rules for \""
-                           + type.getCXXTypeName() + "\"");
-      }
-      info.KindRule = kindRule;
-    }
-
-    // Find all the type cases.
-    for (TypeCase typeCase :
-           records.getAllDerivedDefinitions(TypeCaseClassName)) {
-      CasedTypeInfos[typeCase.getParentType()].Cases.push_back(typeCase);
-    }
-
-    Validator(*this).validate();
-  }
+        std::vector<PropertyType> AllPropertyTypes;
+        std::map<PropertyType, CasedTypeInfo> CasedTypeInfos;
+
+      public:
+        ASTPropsEmitter(const RecordKeeper &records, raw_ostream &out)
+            : Out(out), Records(records) {
+
+          // Find all the properties.
+          for (Property property :
+               records.getAllDerivedDefinitions(PropertyClassName)) {
+            HasProperties node = property.getClass();
+            NodeInfos[node].Properties.push_back(property);
+          }
+
+          // Find all the creation rules.
+          for (CreationRule creationRule :
+               records.getAllDerivedDefinitions(CreationRuleClassName)) {
+            HasProperties node = creationRule.getClass();
+
+            auto &info = NodeInfos[node];
+            if (info.Creator) {
+              PrintFatalError(creationRule.getLoc(),
+                              "multiple creator rules for \"" + node.getName() +
+                                  "\"");
+            }
+            info.Creator = creationRule;
+          }
+
+          // Find all the override rules.
+          for (OverrideRule overrideRule :
+               records.getAllDerivedDefinitions(OverrideRuleClassName)) {
+            HasProperties node = overrideRule.getClass();
+
+            auto &info = NodeInfos[node];
+            if (info.Override) {
+              PrintFatalError(overrideRule.getLoc(),
+                              "multiple override rules for \"" +
+                                  node.getName() + "\"");
+            }
+            info.Override = overrideRule;
+          }
+
+          // Find all the write helper rules.
+          for (ReadHelperRule helperRule :
+               records.getAllDerivedDefinitions(ReadHelperRuleClassName)) {
+            HasProperties node = helperRule.getClass();
+
+            auto &info = NodeInfos[node];
+            if (info.ReadHelper) {
+              PrintFatalError(helperRule.getLoc(),
+                              "multiple write helper rules for \"" +
+                                  node.getName() + "\"");
+            }
+            info.ReadHelper = helperRule;
+          }
+
+          // Find all the concrete property types.
+          for (PropertyType type :
+               records.getAllDerivedDefinitions(PropertyTypeClassName)) {
+            // Ignore generic specializations; they're generally not useful when
+            // emitting basic emitters etc.
+            if (type.isGenericSpecialization())
+              continue;
+
+            AllPropertyTypes.push_back(type);
+          }
+
+          // Find all the type kind rules.
+          for (TypeKindRule kindRule :
+               records.getAllDerivedDefinitions(TypeKindClassName)) {
+            PropertyType type = kindRule.getParentType();
+            auto &info = CasedTypeInfos[type];
+            if (info.KindRule) {
+              PrintFatalError(kindRule.getLoc(), "multiple kind rules for \"" +
+                                                     type.getCXXTypeName() +
+                                                     "\"");
+            }
+            info.KindRule = kindRule;
+          }
+
+          // Find all the type cases.
+          for (TypeCase typeCase :
+               records.getAllDerivedDefinitions(TypeCaseClassName)) {
+            CasedTypeInfos[typeCase.getParentType()].Cases.push_back(typeCase);
+          }
+
+          Validator(*this).validate();
+        }
 
   void visitAllProperties(HasProperties derived, const NodeInfo &derivedInfo,
                           function_ref<void (Property)> visit) {

``````````

</details>


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


More information about the cfe-commits mailing list