]> granicus.if.org Git - clang/commit
ParentMap: Restore the ability to update an existing map.
authorJordan Rose <jordan_rose@apple.com>
Sat, 6 Oct 2012 01:19:36 +0000 (01:19 +0000)
committerJordan Rose <jordan_rose@apple.com>
Sat, 6 Oct 2012 01:19:36 +0000 (01:19 +0000)
commit1e5101e1e52729564b6fc8d7bf146cef33bc31ca
tree357c58e108ba8fa6ede0e6c124385c25d0f31fcb
parentcf4ce93caedca1d91ec5824981f9e45eda20b261
ParentMap: Restore the ability to update an existing map.

The Clang ASTs are a DAG, not a pure tree. However, ParentMap has to
choose a single parent for each object. In the main (only?) cases in
which the AST forms a DAG, it protects from multiple traversal by using
OpaqueValueExprs. Previously, ParentMap would just unconditionally look
through all OpaqueValueExprs when building its map.

In order to make this behavior better for the analyzer's diagnostics,
ParentMap was changed to not set a statement's parent if there already
was one in the map. However, ParentMap is supposed to allow updating
existing mappings by calling addStmt once again. This change makes the
"transparency" of OpaqueValueExprs explicit, and disables it when it
is not desired, rather than checking the current contents of the map.

This new code seems like a big change, but it should actually have
essentially the same performance as before. Only OpaqueValueExprs and
their users (PseudoObjectExpr and BinaryConditionalOperator) will
have any different behavior.

There should be no user-visible functionality change, though a test
has been added for the current behavior of BinaryConditionalOperator
source locations and accompanying Xcode arrows (which are not so great...).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165355 91177308-0d34-0410-b5e6-96231b3b80d8
lib/AST/ParentMap.cpp
test/Analysis/conditional-operator-path-notes.c [new file with mode: 0644]