Skip to content

Commit

Permalink
[analyzer] Fix a crash reported in PR 14400.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
AnnaZaks committed Nov 26, 2012
1 parent f419a85 commit dac6cd5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion lib/StaticAnalyzer/Core/MemRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions test/Analysis/misc-ps-region-store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit dac6cd5

Please sign in to comment.