[llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp

Chris Lattner sabre at nondot.org
Tue Apr 17 17:57:40 PDT 2007



Changes in directory llvm/lib/VMCore:

AsmWriter.cpp updated: 1.269 -> 1.270
---
Log message:

don't access argument list of prototypes


---
Diffs of the changes:  (+24 -7)

 AsmWriter.cpp |   31 ++++++++++++++++++++++++-------
 1 files changed, 24 insertions(+), 7 deletions(-)


Index: llvm/lib/VMCore/AsmWriter.cpp
diff -u llvm/lib/VMCore/AsmWriter.cpp:1.269 llvm/lib/VMCore/AsmWriter.cpp:1.270
--- llvm/lib/VMCore/AsmWriter.cpp:1.269	Thu Apr 12 13:32:50 2007
+++ llvm/lib/VMCore/AsmWriter.cpp	Tue Apr 17 19:57:22 2007
@@ -970,13 +970,30 @@
   // Loop over the arguments, printing them...
 
   unsigned Idx = 1;
-  for (Function::const_arg_iterator I = F->arg_begin(), E = F->arg_end();
-       I != E; ++I) {
-    // Insert commas as we go... the first arg doesn't get a comma
-    if (I != F->arg_begin()) Out << ", ";
-    printArgument(I, (Attrs ? Attrs->getParamAttrs(Idx)
-                            : uint16_t(ParamAttr::None)));
-    Idx++;
+  if (!F->isDeclaration()) {
+    // If this isn't a declaration, print the argument names as well.
+    for (Function::const_arg_iterator I = F->arg_begin(), E = F->arg_end();
+         I != E; ++I) {
+      // Insert commas as we go... the first arg doesn't get a comma
+      if (I != F->arg_begin()) Out << ", ";
+      printArgument(I, (Attrs ? Attrs->getParamAttrs(Idx)
+                              : uint16_t(ParamAttr::None)));
+      Idx++;
+    }
+  } else {
+    // Otherwise, print the types from the function type.
+    for (unsigned i = 0, e = FT->getNumParams(); i != e; ++i) {
+      // Insert commas as we go... the first arg doesn't get a comma
+      if (i) Out << ", ";
+      
+      // Output type...
+      printType(FT->getParamType(i));
+      
+      unsigned ArgAttrs = ParamAttr::None;
+      if (Attrs) ArgAttrs = Attrs->getParamAttrs(i+1);
+      if (ArgAttrs != ParamAttr::None)
+        Out << ' ' << ParamAttrsList::getParamAttrsText(ArgAttrs);
+    }
   }
 
   // Finish printing arguments...






More information about the llvm-commits mailing list