[llvm] r218462 - Refactoring: raw pointer -> unique_ptr

Anton Yartsev anton.yartsev at gmail.com
Thu Sep 25 12:55:59 PDT 2014


Author: ayartsev
Date: Thu Sep 25 14:55:58 2014
New Revision: 218462

URL: http://llvm.org/viewvc/llvm-project?rev=218462&view=rev
Log:
Refactoring: raw pointer -> unique_ptr

Modified:
    llvm/trunk/lib/TableGen/TGParser.cpp

Modified: llvm/trunk/lib/TableGen/TGParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGParser.cpp?rev=218462&r1=218461&r2=218462&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/TGParser.cpp (original)
+++ llvm/trunk/lib/TableGen/TGParser.cpp Thu Sep 25 14:55:58 2014
@@ -232,16 +232,14 @@ bool TGParser::AddSubMultiClass(MultiCla
        i != iend;
        ++i) {
     // Clone the def and add it to the current multiclass
-    Record *NewDef = new Record(**i);
+    auto NewDef = make_unique<Record>(**i);
 
     // Add all of the values in the superclass into the current def.
     for (unsigned i = 0, e = MCVals.size(); i != e; ++i)
-      if (AddValue(NewDef, SubMultiClass.RefRange.Start, MCVals[i])) {
-        delete NewDef;
+      if (AddValue(NewDef.get(), SubMultiClass.RefRange.Start, MCVals[i]))
         return true;
-      }
 
-    CurMC->DefPrototypes.push_back(NewDef);
+    CurMC->DefPrototypes.push_back(NewDef.release());
   }
 
   const std::vector<Init *> &SMCTArgs = SMC->Rec.getTemplateArgs();





More information about the llvm-commits mailing list