r258066 - [TableGen] Merge the SuperClass Record and SMRange vector a single vector. This removes the state needed to manage the extract vector. NFC

Craig Topper via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 18 11:52:55 PST 2016


Author: ctopper
Date: Mon Jan 18 13:52:54 2016
New Revision: 258066

URL: http://llvm.org/viewvc/llvm-project?rev=258066&view=rev
Log:
[TableGen] Merge the SuperClass Record and SMRange vector a single vector. This removes the state needed to manage the extract vector. NFC

Modified:
    cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
    cfe/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp
    cfe/trunk/utils/TableGen/NeonEmitter.cpp

Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=258066&r1=258065&r2=258066&view=diff
==============================================================================
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Mon Jan 18 13:52:54 2016
@@ -1072,9 +1072,9 @@ createArgument(const Record &Arg, String
 
   if (!Ptr) {
     // Search in reverse order so that the most-derived type is handled first.
-    ArrayRef<Record*> Bases = Search->getSuperClasses();
-    for (const auto *Base : llvm::make_range(Bases.rbegin(), Bases.rend())) {
-      if ((Ptr = createArgument(Arg, Attr, Base)))
+    ArrayRef<std::pair<Record*, SMRange>> Bases = Search->getSuperClasses();
+    for (const auto &Base : llvm::make_range(Bases.rbegin(), Bases.rend())) {
+      if ((Ptr = createArgument(Arg, Attr, Base.first)))
         break;
     }
   }
@@ -1381,7 +1381,7 @@ static void emitClangAttrTypeArgList(Rec
     if (Args.empty())
       continue;
 
-    if (Args[0]->getSuperClasses().back()->getName() != "TypeArgument")
+    if (Args[0]->getSuperClasses().back().first->getName() != "TypeArgument")
       continue;
 
     // All these spellings take a single type argument.
@@ -1419,7 +1419,7 @@ static void emitClangAttrArgContextList(
 
 static bool isIdentifierArgument(Record *Arg) {
   return !Arg->getSuperClasses().empty() &&
-    llvm::StringSwitch<bool>(Arg->getSuperClasses().back()->getName())
+    llvm::StringSwitch<bool>(Arg->getSuperClasses().back().first->getName())
     .Case("IdentifierArgument", true)
     .Case("EnumArgument", true)
     .Case("VariadicEnumArgument", true)
@@ -1476,13 +1476,13 @@ void EmitClangAttrClass(RecordKeeper &Re
     if (!R.getValueAsBit("ASTNode"))
       continue;
     
-    ArrayRef<Record *> Supers = R.getSuperClasses();
+    ArrayRef<std::pair<Record *, SMRange>> Supers = R.getSuperClasses();
     assert(!Supers.empty() && "Forgot to specify a superclass for the attr");
     std::string SuperName;
-    for (const auto *Super : llvm::make_range(Supers.rbegin(), Supers.rend())) {
-      const Record &R = *Super;
-      if (R.getName() != "TargetSpecificAttr" && SuperName.empty())
-        SuperName = R.getName();
+    for (const auto &Super : llvm::make_range(Supers.rbegin(), Supers.rend())) {
+      const Record *R = Super.first;
+      if (R->getName() != "TargetSpecificAttr" && SuperName.empty())
+        SuperName = R->getName();
     }
 
     OS << "class " << R.getName() << "Attr : public " << SuperName << " {\n";

Modified: cfe/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp?rev=258066&r1=258065&r2=258066&view=diff
==============================================================================
--- cfe/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp Mon Jan 18 13:52:54 2016
@@ -152,13 +152,12 @@ static bool beforeThanCompareGroups(cons
 }
 
 static SMRange findSuperClassRange(const Record *R, StringRef SuperName) {
-  ArrayRef<Record *> Supers = R->getSuperClasses();
-
-  for (size_t i = 0, e = Supers.size(); i < e; ++i)
-    if (Supers[i]->getName() == SuperName)
-      return R->getSuperClassRanges()[i];
-
-  return SMRange();
+  ArrayRef<std::pair<Record *, SMRange>> Supers = R->getSuperClasses();
+  auto I = std::find_if(Supers.begin(), Supers.end(),
+                        [&](const std::pair<Record *, SMRange> &SuperPair) {
+                          return SuperPair.first->getName() == SuperName;
+                        });
+  return (I != Supers.end()) ? I->second : SMRange();
 }
 
 /// \brief Invert the 1-[0/1] mapping of diags to group into a one to many

Modified: cfe/trunk/utils/TableGen/NeonEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/NeonEmitter.cpp?rev=258066&r1=258065&r2=258066&view=diff
==============================================================================
--- cfe/trunk/utils/TableGen/NeonEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/NeonEmitter.cpp Mon Jan 18 13:52:54 2016
@@ -1926,7 +1926,7 @@ void NeonEmitter::createIntrinsic(Record
 
   ClassKind CK = ClassNone;
   if (R->getSuperClasses().size() >= 2)
-    CK = ClassMap[R->getSuperClasses()[1]];
+    CK = ClassMap[R->getSuperClasses()[1].first];
 
   std::vector<std::pair<TypeSpec, TypeSpec>> NewTypeSpecs;
   for (auto TS : TypeSpecs) {




More information about the cfe-commits mailing list