diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-08-12 04:09:00 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-08-12 04:09:00 +0000 |
commit | 06b8cd73247f2238ca436271a7e62367db5f747c (patch) | |
tree | fb95d216c61da960991d00b0f7eb6661eb35cfcd /clang/lib/Analysis | |
parent | 4826b7f13a0705455c6d7fce11e976f46c8615e6 (diff) | |
download | bcm5719-llvm-06b8cd73247f2238ca436271a7e62367db5f747c.tar.gz bcm5719-llvm-06b8cd73247f2238ca436271a7e62367db5f747c.zip |
Fix crash in CFGBuilder involving implicit destructor calls and gotos jumping after an object was declared. Fixes PR 10620.
llvm-svn: 137426
Diffstat (limited to 'clang/lib/Analysis')
-rw-r--r-- | clang/lib/Analysis/CFG.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp index 1edb328d013..ea126a96894 100644 --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/lib/Analysis/CFG.cpp @@ -191,8 +191,8 @@ int LocalScope::const_iterator::distance(LocalScope::const_iterator L) { int D = 0; const_iterator F = *this; while (F.Scope != L.Scope) { - assert (F != const_iterator() - && "L iterator is not reachable from F iterator."); + if (F == const_iterator()) + return D; D += F.VarIter; F = F.Scope->Prev; } @@ -816,10 +816,12 @@ void CFGBuilder::addLocalScopeAndDtors(Stmt* S) { /// performed in place specified with iterator. void CFGBuilder::insertAutomaticObjDtors(CFGBlock* Blk, CFGBlock::iterator I, LocalScope::const_iterator B, LocalScope::const_iterator E, Stmt* S) { - BumpVectorContext& C = cfg->getBumpVectorContext(); - I = Blk->beginAutomaticObjDtorsInsert(I, B.distance(E), C); - while (B != E) - I = Blk->insertAutomaticObjDtor(I, *B++, S); + if (int Cnt = B.distance(E)) { + BumpVectorContext& C = cfg->getBumpVectorContext(); + I = Blk->beginAutomaticObjDtorsInsert(I, Cnt, C); + while (B != E) + I = Blk->insertAutomaticObjDtor(I, *B++, S); + } } /// appendAutomaticObjDtors - Append destructor CFGElements for variables with |