[llvm] b8b8fbe - [NFC][TableGen] Migrate LLVM Attribute Emitter to const RecordKeeper (#107698)

via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 9 04:18:58 PDT 2024


Author: Rahul Joshi
Date: 2024-09-09T04:18:55-07:00
New Revision: b8b8fbe19dea2825b801c4738ff78dbf26aae430

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

LOG: [NFC][TableGen] Migrate LLVM Attribute Emitter to const RecordKeeper (#107698)

Migrate LLVM Attribute Emitter to const RecordKeeper.

Added: 
    

Modified: 
    llvm/utils/TableGen/Attributes.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/utils/TableGen/Attributes.cpp b/llvm/utils/TableGen/Attributes.cpp
index c50316985ef098..8d16ff89aae0f2 100644
--- a/llvm/utils/TableGen/Attributes.cpp
+++ b/llvm/utils/TableGen/Attributes.cpp
@@ -17,7 +17,7 @@ namespace {
 
 class Attributes {
 public:
-  Attributes(RecordKeeper &R) : Records(R) {}
+  Attributes(const RecordKeeper &R) : Records(R) {}
   void run(raw_ostream &OS);
 
 private:
@@ -25,7 +25,7 @@ class Attributes {
   void emitFnAttrCompatCheck(raw_ostream &OS, bool IsStringAttr);
   void emitAttributeProperties(raw_ostream &OF);
 
-  RecordKeeper &Records;
+  const RecordKeeper &Records;
 };
 
 } // End anonymous namespace.
@@ -85,10 +85,7 @@ void Attributes::emitFnAttrCompatCheck(raw_ostream &OS, bool IsStringAttr) {
      << "                                        const Function &Callee) {\n";
   OS << "  bool Ret = true;\n\n";
 
-  std::vector<Record *> CompatRules =
-      Records.getAllDerivedDefinitions("CompatRule");
-
-  for (auto *Rule : CompatRules) {
+  for (const Record *Rule : Records.getAllDerivedDefinitions("CompatRule")) {
     StringRef FuncName = Rule->getValueAsString("CompatFunc");
     OS << "  Ret &= " << FuncName << "(Caller, Callee";
     StringRef AttrName = Rule->getValueAsString("AttrName");
@@ -101,12 +98,10 @@ void Attributes::emitFnAttrCompatCheck(raw_ostream &OS, bool IsStringAttr) {
   OS << "  return Ret;\n";
   OS << "}\n\n";
 
-  std::vector<Record *> MergeRules =
-      Records.getAllDerivedDefinitions("MergeRule");
   OS << "static inline void mergeFnAttrs(Function &Caller,\n"
      << "                                const Function &Callee) {\n";
 
-  for (auto *Rule : MergeRules) {
+  for (const Record *Rule : Records.getAllDerivedDefinitions("MergeRule")) {
     StringRef FuncName = Rule->getValueAsString("MergeFunc");
     OS << "  " << FuncName << "(Caller, Callee);\n";
   }


        


More information about the llvm-commits mailing list