Fix partial-match-bind-behavior with forEachDescendant() matchers.
authorDaniel Jasper <djasper@google.com>
Fri, 16 Nov 2012 18:39:22 +0000 (18:39 +0000)
committerDaniel Jasper <djasper@google.com>
Fri, 16 Nov 2012 18:39:22 +0000 (18:39 +0000)
commit94a56856d24e5f8c5c30c4bec2dbca15bd2d6076
treeabe2903e532f927605b029522b5e0b31168bb0ad
parent7b8af0ea058f3d2f269ad99db8d14614e3df9ddf
Fix partial-match-bind-behavior with forEachDescendant() matchers.

The problem is that a partial match of an (explicit or implicit) allOf matcher
binds results, i.e.

recordDecl(decl().bind("x"), hasName("A"))

can very well bind a record that is not named "A". With this fix, the common
cases of stumbling over this bug are fixed by the BoundNodesMap overwriting the
results of a partial match. An error can still be created with a weird
combination of anyOf and allOf (see inactive test). We need to decide whether
this is worth fixing, as the fix will have performance impact.

Review: http://llvm-reviews.chandlerc.com/D124
llvm-svn: 168177
clang/lib/ASTMatchers/ASTMatchersInternal.cpp
clang/unittests/ASTMatchers/ASTMatchersTest.cpp