]> granicus.if.org Git - clang/commit
[analyzer; new edges] Simplify edges in a C++11 for-range loop.
authorJordan Rose <jordan_rose@apple.com>
Thu, 6 Jun 2013 21:53:45 +0000 (21:53 +0000)
committerJordan Rose <jordan_rose@apple.com>
Thu, 6 Jun 2013 21:53:45 +0000 (21:53 +0000)
commit49a246f4fad959888bb0164c624c3c2b03078e91
tree82edcc53b9a4fc2803a824838d1c0dd483f52f94
parentc09f2a865c912ee5d81bee7586c77a73ad302fd7
[analyzer; new edges] Simplify edges in a C++11 for-range loop.

Previously our edges were completely broken here; now, the final result
is a very simple set of edges in most cases: one up to the "for" keyword
for context, and one into the body of the loop. This matches the behavior
for ObjC for-in loops.

In the AST, however, CXXForRangeStmts are handled very differently from
ObjCForCollectionStmts. Since they are specified in terms of equivalent
statements in the C++ standard, we actually have implicit AST nodes for
all of the semantic statements. This makes evaluation very easy, but
diagnostic locations a bit trickier. Fortunately, the problem can be
generally defined away by marking all of the implicit statements as
part of the top-level for-range statement.

One of the implicit statements in a for-range statement is the declaration
of implicit iterators __begin and __end. The CFG synthesizes two
separate DeclStmts to match each of these decls, but until now these
synthetic DeclStmts weren't in the function's ParentMap. Now, the CFG
keeps track of its synthetic statements, and the AnalysisDeclContext will
make sure to add them to the ParentMap.

<rdar://problem/14038483>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183449 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/AST/ParentMap.h
include/clang/Analysis/CFG.h
lib/AST/ParentMap.cpp
lib/Analysis/AnalysisDeclContext.cpp
lib/Analysis/CFG.cpp
lib/StaticAnalyzer/Core/BugReporter.cpp
test/Analysis/cxx-for-range.cpp [new file with mode: 0644]
test/Analysis/edges-new.mm