diff options
author | Daniel Jasper <djasper@google.com> | 2012-11-16 18:39:22 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2012-11-16 18:39:22 +0000 |
commit | 5f684e90c2f44eda979573a01c2ed063d9adc7a8 (patch) | |
tree | d691a7d2693cd040b8a0021d0e1732083b134809 /lib/ASTMatchers | |
parent | 58782bee56bf5e6ab42e6695af9ae5befe1fd479 (diff) |
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
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168177 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ASTMatchers')
-rw-r--r-- | lib/ASTMatchers/ASTMatchersInternal.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/ASTMatchers/ASTMatchersInternal.cpp b/lib/ASTMatchers/ASTMatchersInternal.cpp index 408195d369..f1a9ff2e09 100644 --- a/lib/ASTMatchers/ASTMatchersInternal.cpp +++ b/lib/ASTMatchers/ASTMatchersInternal.cpp @@ -27,8 +27,11 @@ void BoundNodesMap::copyTo(BoundNodesTreeBuilder *Builder) const { } void BoundNodesMap::copyTo(BoundNodesMap *Other) const { - copy(NodeMap.begin(), NodeMap.end(), - inserter(Other->NodeMap, Other->NodeMap.begin())); + for (IDToNodeMap::const_iterator I = NodeMap.begin(), + E = NodeMap.end(); + I != E; ++I) { + Other->NodeMap[I->first] = I->second; + } } BoundNodesTree::BoundNodesTree() {} |