[llvm-commits] [llvm] r45852 - /llvm/trunk/lib/Target/CBackend/CBackend.cpp

Evan Cheng evan.cheng at apple.com
Thu Jan 10 19:07:46 PST 2008


Author: evancheng
Date: Thu Jan 10 21:07:46 2008
New Revision: 45852

URL: http://llvm.org/viewvc/llvm-project?rev=45852&view=rev
Log:
A couple of obvious off-by-one bugs.

Modified:
    llvm/trunk/lib/Target/CBackend/CBackend.cpp

Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/CBackend.cpp?rev=45852&r1=45851&r2=45852&view=diff

==============================================================================
--- llvm/trunk/lib/Target/CBackend/CBackend.cpp (original)
+++ llvm/trunk/lib/Target/CBackend/CBackend.cpp Thu Jan 10 21:07:46 2008
@@ -366,10 +366,11 @@
   FunctionType::param_iterator I = FTy->param_begin(), E = FTy->param_end();
   const Type *RetTy = cast<PointerType>(I->get())->getElementType();
   unsigned Idx = 1;
-  for (++I; I != E; ++I) {
+  for (++I, ++Idx; I != E; ++I, ++Idx) {
     if (PrintedType)
       FunctionInnards << ", ";
-    printType(FunctionInnards, *I, 
+    const Type *ArgTy = *I;
+    printType(FunctionInnards, ArgTy,
         /*isSigned=*/PAL && PAL->paramHasAttr(Idx, ParamAttr::SExt), "");
     PrintedType = true;
   }
@@ -1866,23 +1867,25 @@
   if (!F->isDeclaration()) {
     if (!F->arg_empty()) {
       Function::const_arg_iterator I = F->arg_begin(), E = F->arg_end();
+      unsigned Idx = 1;
       
       // If this is a struct-return function, don't print the hidden
       // struct-return argument.
       if (isStructReturn) {
         assert(I != E && "Invalid struct return function!");
         ++I;
+        ++Idx;
       }
       
       std::string ArgName;
-      unsigned Idx = 1;
       for (; I != E; ++I) {
         if (PrintedArg) FunctionInnards << ", ";
         if (I->hasName() || !Prototype)
           ArgName = GetValueName(I);
         else
           ArgName = "";
-        printType(FunctionInnards, I->getType(), 
+        const Type *ArgTy = I->getType();
+        printType(FunctionInnards, ArgTy,
             /*isSigned=*/PAL && PAL->paramHasAttr(Idx, ParamAttr::SExt),
             ArgName);
         PrintedArg = true;





More information about the llvm-commits mailing list