From d753f3c62bfb85e5955b60eb77c3451548745fc1 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Tue, 4 Mar 2008 22:01:56 +0000 Subject: [PATCH] For the transfer function for CallExpr, invalidate all arguments passed-by-reference to builtin functions until we have better builtin support. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47910 91177308-0d34-0410-b5e6-96231b3b80d8 --- Analysis/GRExprEngine.cpp | 63 +++++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 19 deletions(-) diff --git a/Analysis/GRExprEngine.cpp b/Analysis/GRExprEngine.cpp index 7a0ca71054..e7f6f77859 100644 --- a/Analysis/GRExprEngine.cpp +++ b/Analysis/GRExprEngine.cpp @@ -481,26 +481,11 @@ void GRExprEngine::VisitCall(CallExpr* CE, NodeTy* Pred, if (AI != AE) { NodeSet DstTmp; - Visit(*AI, Pred, DstTmp); - - Expr* CurrentArg = *AI; + Visit(*AI, Pred, DstTmp); ++AI; - for (NodeSet::iterator DI=DstTmp.begin(), DE=DstTmp.end(); DI != DE; ++DI) { - if (GetRVal((*DI)->getState(), CurrentArg).isUndef()) { - - NodeTy* N = Builder->generateNode(CE, (*DI)->getState(), *DI); - - if (N) { - N->markAsSink(); - UndefArgs[N] = CurrentArg; - } - - continue; - } - + for (NodeSet::iterator DI=DstTmp.begin(), DE=DstTmp.end(); DI != DE; ++DI) VisitCall(CE, *DI, AI, AE, Dst); - } return; } @@ -529,16 +514,30 @@ void GRExprEngine::VisitCall(CallExpr* CE, NodeTy* Pred, if (L.isUndef() || isa(L)) { NodeTy* N = Builder->generateNode(CE, St, *DI); + if (N) { N->markAsSink(); BadCalls.insert(N); } + continue; } - // Check for an "unknown" callee. + bool invalidateArgs = false; if (L.isUnknown()) { + // Check for an "unknown" callee. + invalidateArgs = true; + } + else if (isa(L)) { + + IdentifierInfo* Info = cast(L).getDecl()->getIdentifier(); + + if (Info->getBuiltinID()) + invalidateArgs = true; + } + + if (invalidateArgs) { // Invalidate all arguments passed in by reference (LVals). for (CallExpr::arg_iterator I = CE->arg_begin(), E = CE->arg_end(); I != E; ++I) { @@ -548,8 +547,34 @@ void GRExprEngine::VisitCall(CallExpr* CE, NodeTy* Pred, St = SetRVal(St, cast(V), UnknownVal()); } } - else + else { + + // Check any arguments passed-by-value against being undefined. + + bool badArg = false; + + for (CallExpr::arg_iterator I = CE->arg_begin(), E = CE->arg_end(); + I != E; ++I) { + + if (GetRVal((*DI)->getState(), *I).isUndef()) { + NodeTy* N = Builder->generateNode(CE, (*DI)->getState(), *DI); + + if (N) { + N->markAsSink(); + UndefArgs[N] = *I; + } + + badArg = true; + break; + } + } + + if (badArg) + continue; + + // Dispatch to the plug-in transfer function. St = EvalCall(CE, cast(L), (*DI)->getState()); + } // Check for the "noreturn" attribute. -- 2.40.0