[llvm-commits] [poolalloc] r134063 - /poolalloc/trunk/lib/AssistDS/TypeChecks.cpp
Arushi Aggarwal
aggarwa4 at illinois.edu
Wed Jun 29 03:28:53 PDT 2011
Author: aggarwa4
Date: Wed Jun 29 05:28:53 2011
New Revision: 134063
URL: http://llvm.org/viewvc/llvm-project?rev=134063&view=rev
Log:
Add support for library functions used by thttpd, in the
hope of removing some false positives, to reveal possible
real errors.
Modified:
poolalloc/trunk/lib/AssistDS/TypeChecks.cpp
Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeChecks.cpp?rev=134063&r1=134062&r2=134063&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/TypeChecks.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Wed Jun 29 05:28:53 2011
@@ -1614,10 +1614,20 @@
Constant *F = M.getOrInsertFunction("trackgetcwd", VoidTy, VoidPtrTy, Int32Ty, NULL);
CallInst *CI = CallInst::Create(F, Args.begin(), Args.end());
CI->insertAfter(BCI);
+ } else if(F->getNameStr() == std::string("crypt")) {
+ CastInst *BCI = BitCastInst::CreatePointerCast(I, VoidPtrTy);
+ BCI->insertAfter(I);
+ std::vector<Value *>Args;
+ Args.push_back(BCI);
+ Args.push_back(getTagCounter());
+ Constant *F = M.getOrInsertFunction("trackgetcwd", VoidTy, VoidPtrTy, Int32Ty, NULL);
+ CallInst *CI = CallInst::Create(F, Args.begin(), Args.end());
+ CI->insertAfter(BCI);
} else if (F->getNameStr() == std::string("getrusage") ||
F->getNameStr() == std::string("getrlimit") ||
F->getNameStr() == std::string("stat") ||
- F->getNameStr() == std::string("fstat")) {
+ F->getNameStr() == std::string("fstat") ||
+ F->getNameStr() == std::string("lstat")) {
CastInst *BCI = BitCastInst::CreatePointerCast(CS.getArgument(1), VoidPtrTy, "", I);
assert (isa<PointerType>(CS.getArgument(1)->getType()));
const PointerType * PT = cast<PointerType>(CS.getArgument(1)->getType());
@@ -1709,7 +1719,30 @@
Args.push_back(getTagCounter());
CallInst *CI = CallInst::Create(trackInitInst, Args.begin(), Args.end());
CI->insertAfter(I);
- } else if (F->getNameStr() == std::string("localtime")) {
+ } else if (F->getNameStr() == std::string("getsockname")) {
+ CastInst *BCI = BitCastInst::CreatePointerCast(CS.getArgument(1), VoidPtrTy, "", I);
+ const PointerType *PTy = cast<PointerType>(CS.getArgument(1)->getType());
+ const Type * ElementType = PTy->getElementType();
+ std::vector<Value *> Args;
+ Args.push_back(BCI);
+ Args.push_back(getSizeConstant(ElementType));
+ Args.push_back(getTagCounter());
+ CallInst::Create(trackInitInst, Args.begin(), Args.end(), "", I);
+ return true;
+ } else if (F->getNameStr() == std::string("readdir")) {
+ CastInst *BCI = BitCastInst::CreatePointerCast(I, VoidPtrTy);
+ BCI->insertAfter(I);
+ const PointerType *PTy = cast<PointerType>(I->getType());
+ const Type * ElementType = PTy->getElementType();
+ std::vector<Value *>Args;
+ Args.push_back(BCI);
+ Args.push_back(getSizeConstant(ElementType));
+ Args.push_back(getTagCounter());
+ CallInst *CI = CallInst::Create(trackInitInst, Args.begin(), Args.end());
+ CI->insertAfter(BCI);
+ return true;
+ } else if (F->getNameStr() == std::string("localtime") ||
+ F->getNameStr() == std::string("gmtime")) {
CastInst *BCI = BitCastInst::CreatePointerCast(I, VoidPtrTy);
BCI->insertAfter(I);
const PointerType *PTy = cast<PointerType>(I->getType());
@@ -1799,6 +1832,15 @@
Args.push_back(getTagCounter());
CallInst::Create(trackInitInst, Args.begin(), Args.end(), "", I);
return true;
+ } else if(F->getNameStr() == std::string("snprintf") ||
+ F->getNameStr() == std::string("vsnprintf")) {
+ CastInst *BCI = BitCastInst::CreatePointerCast(CS.getArgument(0), VoidPtrTy, "", I);
+ std::vector<Value*>Args;
+ Args.push_back(BCI);
+ Args.push_back(getTagCounter());
+ Constant *F = M.getOrInsertFunction("trackgetcwd", VoidTy, VoidPtrTy, Int32Ty, NULL);
+ CallInst *CINew = CallInst::Create(F, Args.begin(), Args.end());
+ CINew->insertAfter(I);
} else if(F->getNameStr() == std::string("sprintf")) {
CastInst *BCI = BitCastInst::CreatePointerCast(CS.getArgument(0), VoidPtrTy, "", I);
std::vector<Value*>Args;
More information about the llvm-commits
mailing list