[llvm-commits] [llvm] r145106 - /llvm/trunk/lib/Analysis/MemoryBuiltins.cpp

Benjamin Kramer benny.kra at googlemail.com
Wed Nov 23 09:58:47 PST 2011


Author: d0k
Date: Wed Nov 23 11:58:47 2011
New Revision: 145106

URL: http://llvm.org/viewvc/llvm-project?rev=145106&view=rev
Log:
Validate the return type when checking if a function is malloc.

Fixes PR11426. Not sure if a test case with a "wrong" malloc would be useful.

Modified:
    llvm/trunk/lib/Analysis/MemoryBuiltins.cpp

Modified: llvm/trunk/lib/Analysis/MemoryBuiltins.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryBuiltins.cpp?rev=145106&r1=145105&r2=145106&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/MemoryBuiltins.cpp (original)
+++ llvm/trunk/lib/Analysis/MemoryBuiltins.cpp Wed Nov 23 11:58:47 2011
@@ -48,10 +48,10 @@
   // FIXME: workaround for PR5130, this will be obsolete when a nobuiltin 
   // attribute will exist.
   FunctionType *FTy = Callee->getFunctionType();
-  if (FTy->getNumParams() != 1)
-    return false;
-  return FTy->getParamType(0)->isIntegerTy(32) ||
-         FTy->getParamType(0)->isIntegerTy(64);
+  return FTy->getReturnType() == Type::getInt8PtrTy(FTy->getContext()) &&
+         FTy->getNumParams() == 1 &&
+         (FTy->getParamType(0)->isIntegerTy(32) ||
+          FTy->getParamType(0)->isIntegerTy(64));
 }
 
 /// extractMallocCall - Returns the corresponding CallInst if the instruction





More information about the llvm-commits mailing list