[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y

Reid Spencer reid at x10sys.com
Sat Apr 21 22:47:19 PDT 2007



Changes in directory llvm/lib/AsmParser:

llvmAsmParser.y updated: 1.345 -> 1.346
---
Log message:

For PR1146: http://llvm.org/PR1146 :
Make ParamAttrsList objects unique. You can no longer directly create or
destroy them but instead must go through the ParamAttrsList::get() 
interface.


---
Diffs of the changes:  (+59 -40)

 llvmAsmParser.y |   99 +++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 59 insertions(+), 40 deletions(-)


Index: llvm/lib/AsmParser/llvmAsmParser.y
diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.345 llvm/lib/AsmParser/llvmAsmParser.y:1.346
--- llvm/lib/AsmParser/llvmAsmParser.y:1.345	Sat Apr 21 13:36:27 2007
+++ llvm/lib/AsmParser/llvmAsmParser.y	Sun Apr 22 00:46:44 2007
@@ -1299,24 +1299,28 @@
   }
   | Types '(' ArgTypeListI ')' OptFuncAttrs {
     std::vector<const Type*> Params;
-    ParamAttrsList Attrs;
-    if ($5 != ParamAttr::None)
-      Attrs.addAttributes(0, $5);
+    ParamAttrsVector Attrs;
+    if ($5 != ParamAttr::None) {
+      ParamAttrsWithIndex X; X.index = 0; X.attrs = $5;
+      Attrs.push_back(X);
+    }
     unsigned index = 1;
     TypeWithAttrsList::iterator I = $3->begin(), E = $3->end();
     for (; I != E; ++I, ++index) {
       const Type *Ty = I->Ty->get();
       Params.push_back(Ty);
       if (Ty != Type::VoidTy)
-        if (I->Attrs != ParamAttr::None)
-          Attrs.addAttributes(index, I->Attrs);
+        if (I->Attrs != ParamAttr::None) {
+          ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
+          Attrs.push_back(X);
+        }
     }
     bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
     if (isVarArg) Params.pop_back();
 
     ParamAttrsList *ActualAttrs = 0;
     if (!Attrs.empty())
-      ActualAttrs = new ParamAttrsList(Attrs);
+      ActualAttrs = ParamAttrsList::get(Attrs);
     FunctionType *FT = FunctionType::get(*$1, Params, isVarArg, ActualAttrs);
     delete $3;   // Delete the argument list
     delete $1;   // Delete the return type handle
@@ -1325,24 +1329,28 @@
   }
   | VOID '(' ArgTypeListI ')' OptFuncAttrs {
     std::vector<const Type*> Params;
-    ParamAttrsList Attrs;
-    if ($5 != ParamAttr::None)
-      Attrs.addAttributes(0, $5);
+    ParamAttrsVector Attrs;
+    if ($5 != ParamAttr::None) {
+      ParamAttrsWithIndex X; X.index = 0; X.attrs = $5;
+      Attrs.push_back(X);
+    }
     TypeWithAttrsList::iterator I = $3->begin(), E = $3->end();
     unsigned index = 1;
     for ( ; I != E; ++I, ++index) {
       const Type* Ty = I->Ty->get();
       Params.push_back(Ty);
       if (Ty != Type::VoidTy)
-        if (I->Attrs != ParamAttr::None)
-          Attrs.addAttributes(index, I->Attrs);
+        if (I->Attrs != ParamAttr::None) {
+          ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
+          Attrs.push_back(X);
+        }
     }
     bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
     if (isVarArg) Params.pop_back();
 
     ParamAttrsList *ActualAttrs = 0;
     if (!Attrs.empty())
-      ActualAttrs = new ParamAttrsList(Attrs);
+      ActualAttrs = ParamAttrsList::get(Attrs);
 
     FunctionType *FT = FunctionType::get($1, Params, isVarArg, ActualAttrs);
     delete $3;      // Delete the argument list
@@ -2135,9 +2143,11 @@
     GEN_ERROR("Reference to abstract result: "+ $2->get()->getDescription());
 
   std::vector<const Type*> ParamTypeList;
-  ParamAttrsList ParamAttrs;
-  if ($7 != ParamAttr::None)
-    ParamAttrs.addAttributes(0, $7);
+  ParamAttrsVector Attrs;
+  if ($7 != ParamAttr::None) {
+    ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = $7;
+    Attrs.push_back(PAWI);
+  }
   if ($5) {   // If there are arguments...
     unsigned index = 1;
     for (ArgListType::iterator I = $5->begin(); I != $5->end(); ++I, ++index) {
@@ -2146,20 +2156,21 @@
         GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
       ParamTypeList.push_back(Ty);
       if (Ty != Type::VoidTy)
-        if (I->Attrs != ParamAttr::None)
-          ParamAttrs.addAttributes(index, I->Attrs);
+        if (I->Attrs != ParamAttr::None) {
+          ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
+          Attrs.push_back(PAWI);
+        }
     }
   }
 
   bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
   if (isVarArg) ParamTypeList.pop_back();
 
-  ParamAttrsList *ActualAttrs = 0;
-  if (!ParamAttrs.empty())
-    ActualAttrs = new ParamAttrsList(ParamAttrs);
+  ParamAttrsList *PAL = 0;
+  if (!Attrs.empty())
+    PAL = ParamAttrsList::get(Attrs);
 
-  FunctionType *FT = FunctionType::get(*$2, ParamTypeList, isVarArg, 
-                                       ActualAttrs);
+  FunctionType *FT = FunctionType::get(*$2, ParamTypeList, isVarArg, PAL);
   const PointerType *PFT = PointerType::get(FT);
   delete $2;
 
@@ -2490,9 +2501,11 @@
         !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
       // Pull out the types of all of the arguments...
       std::vector<const Type*> ParamTypes;
-      ParamAttrsList ParamAttrs;
-      if ($8 != ParamAttr::None)
-        ParamAttrs.addAttributes(0, $8);
+      ParamAttrsVector Attrs;
+      if ($8 != ParamAttr::None) {
+        ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = 8;
+        Attrs.push_back(PAWI);
+      }
       ValueRefList::iterator I = $6->begin(), E = $6->end();
       unsigned index = 1;
       for (; I != E; ++I, ++index) {
@@ -2500,14 +2513,16 @@
         if (Ty == Type::VoidTy)
           GEN_ERROR("Short call syntax cannot be used with varargs");
         ParamTypes.push_back(Ty);
-        if (I->Attrs != ParamAttr::None)
-          ParamAttrs.addAttributes(index, I->Attrs);
+        if (I->Attrs != ParamAttr::None) {
+          ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
+          Attrs.push_back(PAWI);
+        }
       }
 
-      ParamAttrsList *Attrs = 0;
-      if (!ParamAttrs.empty())
-        Attrs = new ParamAttrsList(ParamAttrs);
-      Ty = FunctionType::get($3->get(), ParamTypes, false, Attrs);
+      ParamAttrsList *PAL = 0;
+      if (!Attrs.empty())
+        PAL = ParamAttrsList::get(Attrs);
+      Ty = FunctionType::get($3->get(), ParamTypes, false, PAL);
       PFTy = PointerType::get(Ty);
     }
 
@@ -2796,9 +2811,11 @@
         !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
       // Pull out the types of all of the arguments...
       std::vector<const Type*> ParamTypes;
-      ParamAttrsList ParamAttrs;
-      if ($8 != ParamAttr::None)
-        ParamAttrs.addAttributes(0, $8);
+      ParamAttrsVector Attrs;
+      if ($8 != ParamAttr::None) {
+        ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = $8;
+        Attrs.push_back(PAWI);
+      }
       unsigned index = 1;
       ValueRefList::iterator I = $6->begin(), E = $6->end();
       for (; I != E; ++I, ++index) {
@@ -2806,15 +2823,17 @@
         if (Ty == Type::VoidTy)
           GEN_ERROR("Short call syntax cannot be used with varargs");
         ParamTypes.push_back(Ty);
-        if (I->Attrs != ParamAttr::None)
-          ParamAttrs.addAttributes(index, I->Attrs);
+        if (I->Attrs != ParamAttr::None) {
+          ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
+          Attrs.push_back(PAWI);
+        }
       }
 
-      ParamAttrsList *Attrs = 0;
-      if (!ParamAttrs.empty())
-        Attrs = new ParamAttrsList(ParamAttrs);
+      ParamAttrsList *PAL = 0;
+      if (!Attrs.empty())
+        PAL = ParamAttrsList::get(Attrs);
 
-      Ty = FunctionType::get($3->get(), ParamTypes, false, Attrs);
+      Ty = FunctionType::get($3->get(), ParamTypes, false, PAL);
       PFTy = PointerType::get(Ty);
     }
 






More information about the llvm-commits mailing list