diff options
| author | Samuel Benzaquen <sbenza@google.com> | 2014-10-06 13:14:30 +0000 |
|---|---|---|
| committer | Samuel Benzaquen <sbenza@google.com> | 2014-10-06 13:14:30 +0000 |
| commit | a117002d93b1f0e9488a68d5d3b540ca795bc9e5 (patch) | |
| tree | 71f19d127eb772033bf647f2b86152bac7d43702 /clang/lib/AST | |
| parent | faef77480d0ff27dca79b4a60f6863bf97d30854 (diff) | |
| download | bcm5719-llvm-a117002d93b1f0e9488a68d5d3b540ca795bc9e5.tar.gz bcm5719-llvm-a117002d93b1f0e9488a68d5d3b540ca795bc9e5.zip | |
Fix bug in DynTypedMatcher::constructVariadic() that would cause false negatives.
Summary:
DynTypedMatcher::constructVariadic() where the restrict kind of the
different matchers are not related causes the matcher to have a "None"
restrict kind. This causes false negatives for anyOf and eachOf.
Change the logic to get a common ancestor if there is one.
Also added regression tests that fail without the fix.
Reviewers: klimek
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D5580
llvm-svn: 219118
Diffstat (limited to 'clang/lib/AST')
| -rw-r--r-- | clang/lib/AST/ASTTypeTraits.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/lib/AST/ASTTypeTraits.cpp b/clang/lib/AST/ASTTypeTraits.cpp index 56915b96406..ec0671ceb1b 100644 --- a/clang/lib/AST/ASTTypeTraits.cpp +++ b/clang/lib/AST/ASTTypeTraits.cpp @@ -62,6 +62,22 @@ bool ASTNodeKind::isBaseOf(NodeKindId Base, NodeKindId Derived, StringRef ASTNodeKind::asStringRef() const { return AllKindInfo[KindId].Name; } +ASTNodeKind ASTNodeKind::getMostDerivedType(ASTNodeKind Kind1, + ASTNodeKind Kind2) { + if (Kind1.isBaseOf(Kind2)) return Kind2; + if (Kind2.isBaseOf(Kind1)) return Kind1; + return ASTNodeKind(); +} + +ASTNodeKind ASTNodeKind::getMostDerivedCommonAncestor(ASTNodeKind Kind1, + ASTNodeKind Kind2) { + NodeKindId Parent = Kind1.KindId; + while (!isBaseOf(Parent, Kind2.KindId, nullptr) && Parent != NKI_None) { + Parent = AllKindInfo[Parent].ParentId; + } + return ASTNodeKind(Parent); +} + ASTNodeKind ASTNodeKind::getFromNode(const Decl &D) { switch (D.getKind()) { #define DECL(DERIVED, BASE) \ |

