From: Argyrios Kyrtzidis Date: Tue, 1 Mar 2011 01:59:41 +0000 (+0000) Subject: [analyzer] Also make sure that the parameter is coming from the current stack frame. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4ba48c43410a8ad4f32d1d3f684c7d297513e0a1;p=clang [analyzer] Also make sure that the parameter is coming from the current stack frame. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126735 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp b/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp index 307d185fed..63a5917299 100644 --- a/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp @@ -191,12 +191,16 @@ static void setFlag(const GRState *state, SVal val, CheckerContext &C) { C.addTransition(state->set(sym, true)); } -static QualType parameterTypeFromSVal(SVal val) { +static QualType parameterTypeFromSVal(SVal val, CheckerContext &C) { + const StackFrameContext * + SFC = C.getPredecessor()->getLocationContext()->getCurrentStackFrame(); if (const loc::MemRegionVal* X = dyn_cast(&val)) { const MemRegion* R = X->getRegion(); if (const VarRegion *VR = R->getAs()) - if (VR->hasStackParametersStorage()) - return VR->getValueType(); + if (const StackArgumentsSpaceRegion * + stackReg = dyn_cast(VR->getMemorySpace())) + if (stackReg->getStackFrame() == SFC) + return VR->getValueType(); } return QualType(); @@ -218,7 +222,7 @@ void NSOrCFErrorDerefChecker::checkLocation(SVal loc, bool isLoad, // FIXME: Cumbersome! Maybe add hook at construction of SVals at start of // function ? - QualType parmT = parameterTypeFromSVal(loc); + QualType parmT = parameterTypeFromSVal(loc, C); if (parmT.isNull()) return;