]> granicus.if.org Git - clang/commitdiff
[analyzer] Fix a crash reported in PR 14400.
authorAnna Zaks <ganna@apple.com>
Mon, 26 Nov 2012 19:11:46 +0000 (19:11 +0000)
committerAnna Zaks <ganna@apple.com>
Mon, 26 Nov 2012 19:11:46 +0000 (19:11 +0000)
The AllocaRegion did not have the superRegion (based on LocationContext)
as part of it's hash. As a consequence, the AllocaRegions from
different frames were uniqued to be the same region.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168599 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
lib/StaticAnalyzer/Core/MemRegion.cpp
test/Analysis/misc-ps-region-store.cpp

index 6ef022b609259b7cf769b0c03872da00a591986b..24f8cdd74ed40887a1c0d94a69d21c1fe66a061f 100644 (file)
@@ -68,6 +68,7 @@ bool BuiltinFunctionChecker::evalCall(const CallExpr *CE,
     DefinedOrUnknownSVal extentMatchesSizeArg =
       svalBuilder.evalEQ(state, Extent, Size);
     state = state->assume(extentMatchesSizeArg, true);
+    assert(state && "The region should not have any previous constraints");
 
     C.addTransition(state->BindExpr(CE, LCtx, loc::MemRegionVal(R)));
     return true;
index fab10cfd3d047639526199f631aa8df21eadc370..37f65ec31e9d368ee726c7e493f692f1867505f6 100644 (file)
@@ -272,10 +272,11 @@ void ObjCStringRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
 
 void AllocaRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
                                  const Expr *Ex, unsigned cnt,
-                                 const MemRegion *) {
+                                 const MemRegion *superRegion) {
   ID.AddInteger((unsigned) AllocaRegionKind);
   ID.AddPointer(Ex);
   ID.AddInteger(cnt);
+  ID.AddPointer(superRegion);
 }
 
 void AllocaRegion::Profile(llvm::FoldingSetNodeID& ID) const {
index a106cf0604255dcf24cd3cb098827573fe80dccc..adbc5b1df0d3fdd97e6f3ad6fffc53cbf53e3b4f 100644 (file)
@@ -628,3 +628,8 @@ void test_inline() {
   a.bar();
 }
 
+void test_alloca_in_a_recursive_function(int p1) {
+    __builtin_alloca (p1);
+    test_alloca_in_a_recursive_function(1);
+    test_alloca_in_a_recursive_function(2);
+}