[cfe-commits] r44968 - /cfe/trunk/CodeGen/CodeGenModule.cpp

Chris Lattner sabre at nondot.org
Wed Dec 12 16:38:04 PST 2007


Author: lattner
Date: Wed Dec 12 18:38:03 2007
New Revision: 44968

URL: http://llvm.org/viewvc/llvm-project?rev=44968&view=rev
Log:
builtin id 0 is invalid, don't use a slot for it.

Modified:
    cfe/trunk/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CodeGenModule.cpp?rev=44968&r1=44967&r2=44968&view=diff

==============================================================================
--- cfe/trunk/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/CodeGen/CodeGenModule.cpp Wed Dec 12 18:38:03 2007
@@ -518,11 +518,13 @@
 
 /// getBuiltinLibFunction
 llvm::Function *CodeGenModule::getBuiltinLibFunction(unsigned BuiltinID) {
-  if (BuiltinFunctions.size() <= BuiltinID)
-    BuiltinFunctions.resize(BuiltinID+1);
+  if (BuiltinID > BuiltinFunctions.size())
+    BuiltinFunctions.resize(BuiltinID);
   
-  // Already available?
-  llvm::Function *&FunctionSlot = BuiltinFunctions[BuiltinID];
+  // Cache looked up functions.  Since builtin id #0 is invalid we don't reserve
+  // a slot for it.
+  assert(BuiltinID && "Invalid Builtin ID");
+  llvm::Function *&FunctionSlot = BuiltinFunctions[BuiltinID-1];
   if (FunctionSlot)
     return FunctionSlot;
   





More information about the cfe-commits mailing list