summaryrefslogtreecommitdiffstats
path: root/clang/lib/ASTMatchers/Dynamic/VariantValue.cpp
diff options
context:
space:
mode:
authorSamuel Benzaquen <sbenza@google.com>2014-03-10 15:40:23 +0000
committerSamuel Benzaquen <sbenza@google.com>2014-03-10 15:40:23 +0000
commita083935d0ab092d801c726ade8f2d16ea0ca9ba1 (patch)
tree6f3b9a82dc4e42e7dfcabb32456f9d6fe9e3d9c3 /clang/lib/ASTMatchers/Dynamic/VariantValue.cpp
parent84a12e18d3c6006ddd6659cd73aea402ac9d595e (diff)
downloadbcm5719-llvm-a083935d0ab092d801c726ade8f2d16ea0ca9ba1.tar.gz
bcm5719-llvm-a083935d0ab092d801c726ade8f2d16ea0ca9ba1.zip
Add loc() to the dynamic registry.
Summary: Add loc() to the dynamic registry. Other fixes: - Fix the polymorphic variant value to accept an exact match, even if there are other possible conversions. - Fix specifiesTypeLoc() to not crash on an empty NestedNameSpecifierLoc. Reviewers: klimek CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D2928 llvm-svn: 203467
Diffstat (limited to 'clang/lib/ASTMatchers/Dynamic/VariantValue.cpp')
-rw-r--r--clang/lib/ASTMatchers/Dynamic/VariantValue.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/clang/lib/ASTMatchers/Dynamic/VariantValue.cpp b/clang/lib/ASTMatchers/Dynamic/VariantValue.cpp
index e4a02c52252..70d37ca399a 100644
--- a/clang/lib/ASTMatchers/Dynamic/VariantValue.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/VariantValue.cpp
@@ -37,7 +37,8 @@ public:
}
virtual void makeTypedMatcher(MatcherOps &Ops) const {
- if (Ops.canConstructFrom(Matcher))
+ bool Ignore;
+ if (Ops.canConstructFrom(Matcher, Ignore))
Ops.constructFrom(Matcher);
}
@@ -69,15 +70,25 @@ public:
}
virtual void makeTypedMatcher(MatcherOps &Ops) const {
+ bool FoundIsExact = false;
const DynTypedMatcher *Found = NULL;
+ int NumFound = 0;
for (size_t i = 0, e = Matchers.size(); i != e; ++i) {
- if (Ops.canConstructFrom(Matchers[i])) {
- if (Found)
- return;
+ bool IsExactMatch;
+ if (Ops.canConstructFrom(Matchers[i], IsExactMatch)) {
+ if (Found) {
+ if (FoundIsExact) {
+ assert(!IsExactMatch && "We should not have two exact matches.");
+ continue;
+ }
+ }
Found = &Matchers[i];
+ FoundIsExact = IsExactMatch;
+ ++NumFound;
}
}
- if (Found)
+ // We only succeed if we found exactly one, or if we found an exact match.
+ if (Found && (FoundIsExact || NumFound == 1))
Ops.constructFrom(*Found);
}
OpenPOWER on IntegriCloud