From: Benjamin Kramer Date: Fri, 28 Feb 2014 11:12:22 +0000 (+0000) Subject: CFG: Also apply the filter to the first block in a FilteredCFGBlockIterator. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b3e0e91a8ac7b270ee093d328a3871404c94275d;p=clang CFG: Also apply the filter to the first block in a FilteredCFGBlockIterator. PR18999. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202491 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Analysis/CFG.h b/include/clang/Analysis/CFG.h index 077210e789..56ad6af913 100644 --- a/include/clang/Analysis/CFG.h +++ b/include/clang/Analysis/CFG.h @@ -576,11 +576,14 @@ public: IMPL I, E; const FilterOptions F; const CFGBlock *From; - public: + public: explicit FilteredCFGBlockIterator(const IMPL &i, const IMPL &e, - const CFGBlock *from, - const FilterOptions &f) - : I(i), E(e), F(f), From(from) {} + const CFGBlock *from, + const FilterOptions &f) + : I(i), E(e), F(f), From(from) { + while (hasMore() && Filter(*I)) + ++I; + } bool hasMore() const { return I != E; } diff --git a/test/Sema/return.c b/test/Sema/return.c index cfdbe0c5d4..aa2ecda048 100644 --- a/test/Sema/return.c +++ b/test/Sema/return.c @@ -275,3 +275,10 @@ int test34(int x) { return 5; } } + +// PR18999 +int test35() { +lbl: + if (1) + goto lbl; +}