[llvm-branch-commits] [llvm-branch] r136014 - in /llvm/branches/exception-handling-rewrite: include/llvm/Instructions.h lib/VMCore/Instructions.cpp

Bill Wendling isanbard at gmail.com
Mon Jul 25 16:33:48 PDT 2011


Author: void
Date: Mon Jul 25 18:33:48 2011
New Revision: 136014

URL: http://llvm.org/viewvc/llvm-project?rev=136014&view=rev
Log:
Fix some off-by-one errors and remember to increase the NumOperands variable
when adding operands.

Modified:
    llvm/branches/exception-handling-rewrite/include/llvm/Instructions.h
    llvm/branches/exception-handling-rewrite/lib/VMCore/Instructions.cpp

Modified: llvm/branches/exception-handling-rewrite/include/llvm/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/exception-handling-rewrite/include/llvm/Instructions.h?rev=136014&r1=136013&r2=136014&view=diff
==============================================================================
--- llvm/branches/exception-handling-rewrite/include/llvm/Instructions.h (original)
+++ llvm/branches/exception-handling-rewrite/include/llvm/Instructions.h Mon Jul 25 18:33:48 2011
@@ -1882,7 +1882,7 @@
   }
 
   /// getNumClauses - Get the number of clauses for this landing pad.
-  unsigned getNumClauses() const { return getNumOperands(); }
+  unsigned getNumClauses() const { return getNumOperands() - 1; }
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const LandingPadInst *) { return true; }

Modified: llvm/branches/exception-handling-rewrite/lib/VMCore/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/exception-handling-rewrite/lib/VMCore/Instructions.cpp?rev=136014&r1=136013&r2=136014&view=diff
==============================================================================
--- llvm/branches/exception-handling-rewrite/lib/VMCore/Instructions.cpp (original)
+++ llvm/branches/exception-handling-rewrite/lib/VMCore/Instructions.cpp Mon Jul 25 18:33:48 2011
@@ -176,7 +176,6 @@
   ReservedSpace = NumReservedValues;
   NumOperands = 1;
   OperandList = allocHungoffUses(ReservedSpace);
-
   OperandList[0] = PersFn;
   setName(NameStr);
 }
@@ -215,8 +214,9 @@
   unsigned OpNo = getNumOperands();
   if (OpNo + 1 > ReservedSpace)
     growOperands();
-  assert(OpNo + 1 < ReservedSpace && "Growing didn't work!");
+  assert(OpNo < ReservedSpace && "Growing didn't work!");
   ClauseIdxs.push_back(CT);
+  ++NumOperands;
   OperandList[OpNo] = ClauseVal;
 }
 





More information about the llvm-branch-commits mailing list