For the dwarf expression code get the subtarget off of the current
[oota-llvm.git] / lib / TableGen / TGParser.cpp
index d0c50d99aab55ecb0d3dd1c7fbdf354973df5331..f66dfd3749941621b906cd6df8a0f8f3eaa1b831 100644 (file)
@@ -12,6 +12,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "TGParser.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/CommandLine.h"
@@ -269,14 +270,9 @@ bool TGParser::AddSubMultiClass(MultiClass *CurMC,
 
       // If a value is specified for this template arg, set it in the
       // new defs now.
-      for (MultiClass::RecordVector::iterator j =
-             CurMC->DefPrototypes.begin() + newDefStart,
-             jend = CurMC->DefPrototypes.end();
-           j != jend;
-           ++j) {
-        Record *Def = j->get();
-
-        if (SetValue(Def, SubMultiClass.RefRange.Start, SMCTArgs[i],
+      for (const auto &Def :
+             makeArrayRef(CurMC->DefPrototypes).slice(newDefStart)) {
+        if (SetValue(Def.get(), SubMultiClass.RefRange.Start, SMCTArgs[i],
                      std::vector<unsigned>(),
                      SubMultiClass.TemplateArgs[i]))
           return true;
@@ -390,8 +386,7 @@ static bool isObjectStart(tgtok::TokKind K) {
 /// GetNewAnonymousName - Generate a unique anonymous name that can be used as
 /// an identifier.
 std::string TGParser::GetNewAnonymousName() {
-  unsigned Tmp = AnonCounter++; // MSVC2012 ICEs without this.
-  return "anonymous_" + utostr(Tmp);
+  return "anonymous_" + utostr(AnonCounter++);
 }
 
 /// ParseObjectName - If an object name is specified, return it.  Otherwise,
@@ -459,12 +454,12 @@ MultiClass *TGParser::ParseMultiClassID() {
     return nullptr;
   }
 
-  auto it = MultiClasses.find(Lex.getCurStrVal());
-  if (it == MultiClasses.end())
+  MultiClass *Result = MultiClasses[Lex.getCurStrVal()].get();
+  if (!Result)
     TokError("Couldn't find multiclass '" + Lex.getCurStrVal() + "'");
 
   Lex.Lex();
-  return &it->second;
+  return Result;
 }
 
 /// ParseSubClassReference - Parse a reference to a subclass or to a templated
@@ -1681,7 +1676,7 @@ std::vector<Init*> TGParser::ParseValueList(Record *CurRec, Record *ArgsRec,
   unsigned int ArgN = 0;
   if (ArgsRec && !EltTy) {
     const std::vector<Init *> &TArgs = ArgsRec->getTemplateArgs();
-    if (!TArgs.size()) {
+    if (TArgs.empty()) {
       TokError("template argument provided to non-template class");
       return std::vector<Init*>();
     }
@@ -2292,11 +2287,12 @@ bool TGParser::ParseMultiClass() {
 
   auto Result =
     MultiClasses.insert(std::make_pair(Name,
-                                       MultiClass(Name, Lex.getLoc(),Records)));
+                    llvm::make_unique<MultiClass>(Name, Lex.getLoc(),Records)));
+
   if (!Result.second)
     return TokError("multiclass '" + Name + "' already defined");
-  CurMultiClass = &Result.first->second;
 
+  CurMultiClass = Result.first->second.get();
   Lex.Lex();  // Eat the identifier.
 
   // If there are template args, parse them.
@@ -2557,9 +2553,8 @@ bool TGParser::ParseDefm(MultiClass *CurMultiClass) {
     // To instantiate a multiclass, we need to first get the multiclass, then
     // instantiate each def contained in the multiclass with the SubClassRef
     // template parameters.
-    auto it = MultiClasses.find(Ref.Rec->getName());
-    assert(it != MultiClasses.end() && "Didn't lookup multiclass correctly?");
-    MultiClass *MC = &it->second;
+    MultiClass *MC = MultiClasses[Ref.Rec->getName()].get();
+    assert(MC && "Didn't lookup multiclass correctly?");
     std::vector<Init*> &TemplateVals = Ref.TemplateArgs;
 
     // Verify that the correct number of template arguments were specified.