[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 307d185..63a5917 100644
--- a/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
+++ b/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
@@ -191,12 +191,16 @@
C.addTransition(state->set<T>(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<loc::MemRegionVal>(&val)) {
const MemRegion* R = X->getRegion();
if (const VarRegion *VR = R->getAs<VarRegion>())
- if (VR->hasStackParametersStorage())
- return VR->getValueType();
+ if (const StackArgumentsSpaceRegion *
+ stackReg = dyn_cast<StackArgumentsSpaceRegion>(VR->getMemorySpace()))
+ if (stackReg->getStackFrame() == SFC)
+ return VR->getValueType();
}
return QualType();
@@ -218,7 +222,7 @@
// 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;