[llvm-commits] CVS: llvm/tools/llvm2cpp/CppWriter.cpp

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



Changes in directory llvm/tools/llvm2cpp:

CppWriter.cpp updated: 1.47 -> 1.48
---
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:  (+12 -5)

 CppWriter.cpp |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)


Index: llvm/tools/llvm2cpp/CppWriter.cpp
diff -u llvm/tools/llvm2cpp/CppWriter.cpp:1.47 llvm/tools/llvm2cpp/CppWriter.cpp:1.48
--- llvm/tools/llvm2cpp/CppWriter.cpp:1.47	Wed Apr 11 08:02:56 2007
+++ llvm/tools/llvm2cpp/CppWriter.cpp	Sun Apr 22 00:46:44 2007
@@ -461,13 +461,14 @@
       const ParamAttrsList *PAL = FT->getParamAttrs();
       Out << "ParamAttrsList *" << typeName << "_PAL = 0;";
       nl(Out);
-      if (PAL && !PAL->empty()) {
-        Out << typeName << "_PAL = new ParamAttrsList();";
-        nl(Out);
+      if (PAL) {
+        Out << '{'; in(); nl(Out);
+        Out << "ParamAttrsVector Attrs;"; nl(Out);
+        Out << "ParamAttrsWithIndex PAWI;"; nl(Out);
         for (unsigned i = 0; i < PAL->size(); ++i) {
           uint16_t index = PAL->getParamIndex(i);
           uint16_t attrs = PAL->getParamAttrs(index);
-          Out << typeName << "_PAL->addAttributes(" << index << ", 0";
+          Out << "PAWI.index = " << index << "; PAWI.attrs = 0 ";
           if (attrs & ParamAttr::SExt)
             Out << " | ParamAttr::SExt";
           if (attrs & ParamAttr::ZExt)
@@ -480,9 +481,15 @@
             Out << " | ParamAttr::NoReturn";
           if (attrs & ParamAttr::NoUnwind)
             Out << " | ParamAttr::NoUnwind";
-          Out << ");";
+          Out << ";";
+          nl(Out);
+          Out << "Attrs.push_back(PAWI);";
           nl(Out);
         }
+        Out << typeName << "_PAL = ParamAttrsList::get(Attrs);";
+        nl(Out);
+        out(); nl(Out);
+        Out << '}'; nl(Out);
       }
       bool isForward = printTypeInternal(FT->getReturnType());
       std::string retTypeName(getCppName(FT->getReturnType()));






More information about the llvm-commits mailing list