Fix handling of 'free' if it has absolutely no prototype
authorChris Lattner <sabre@nondot.org>
Mon, 11 Aug 2003 15:05:08 +0000 (15:05 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 11 Aug 2003 15:05:08 +0000 (15:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7721 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/IPO/RaiseAllocations.cpp

index 75c2247755cdf48e6cdba26a67d54da28bcdae16..dcfdb34b91e53fc433ed67884fcdca6fffcfd631 100644 (file)
@@ -93,6 +93,13 @@ bool RaiseAllocations::doInitialization(Module &M) {
     FreeFunc = M.getFunction("free", FreeType);
   }
 
+  // One last try, check to see if we can find free as 'int (...)* free'.  This
+  // handles the case where NOTHING was declared.
+  if (FreeFunc == 0) {
+    FreeType = FunctionType::get(Type::IntTy, std::vector<const Type*>(),true);
+    FreeFunc = M.getFunction("free", FreeType);
+  }
+
 
   // Don't mess with locally defined versions of these functions...
   if (MallocFunc && !MallocFunc->isExternal()) MallocFunc = 0;