[cfe-commits] r95478 - in /cfe/trunk: lib/Checker/RegionStore.cpp test/Analysis/misc-ps.m
Ted Kremenek
kremenek at apple.com
Fri Feb 5 19:57:59 PST 2010
Author: kremenek
Date: Fri Feb 5 21:57:59 2010
New Revision: 95478
URL: http://llvm.org/viewvc/llvm-project?rev=95478&view=rev
Log:
Fix regression in RegionStore (from BasicStore) where static variables were not treated as being implicitly initialized to 0 (and instead were getting symbolicated).
Modified:
cfe/trunk/lib/Checker/RegionStore.cpp
cfe/trunk/test/Analysis/misc-ps.m
Modified: cfe/trunk/lib/Checker/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/RegionStore.cpp?rev=95478&r1=95477&r2=95478&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/RegionStore.cpp (original)
+++ cfe/trunk/lib/Checker/RegionStore.cpp Fri Feb 5 21:57:59 2010
@@ -1394,11 +1394,23 @@
// Lazily derive a value for the VarRegion.
const VarDecl *VD = R->getDecl();
+ QualType T = VD->getType();
+ const MemSpaceRegion *MS = R->getMemorySpace();
+
+ if (isa<UnknownSpaceRegion>(MS) ||
+ isa<StackArgumentsSpaceRegion>(MS))
+ return ValMgr.getRegionValueSymbolVal(R, T);
- if (R->hasGlobalsOrParametersStorage() ||
- isa<UnknownSpaceRegion>(R->getMemorySpace()))
- return ValMgr.getRegionValueSymbolVal(R, VD->getType());
+ if (isa<GlobalsSpaceRegion>(MS)) {
+ if (VD->isFileVarDecl())
+ return ValMgr.getRegionValueSymbolVal(R, T);
+ if (T->isIntegerType())
+ return ValMgr.makeIntVal(0, T);
+
+ return UnknownVal();
+ }
+
return UndefinedVal();
}
Modified: cfe/trunk/test/Analysis/misc-ps.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps.m?rev=95478&r1=95477&r2=95478&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/misc-ps.m (original)
+++ cfe/trunk/test/Analysis/misc-ps.m Fri Feb 5 21:57:59 2010
@@ -901,3 +901,10 @@
return 0;
}
+void rdar7582031_test_static_init_zero() {
+ static unsigned x;
+ if (x == 0)
+ return;
+ int *p = 0;
+ *p = 0xDEADBEEF;
+}
More information about the cfe-commits
mailing list