summaryrefslogtreecommitdiffstats
path: root/clang/lib/ASTMatchers/ASTMatchFinder.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-10-07 19:56:12 +0000
committerDaniel Jasper <djasper@google.com>2015-10-07 19:56:12 +0000
commitd1ac50ecaa07ffd6c4b56919697e36cd642b72b4 (patch)
treeb90e08b9f39cf19c6f82536b66ddfd2cb9d27fae /clang/lib/ASTMatchers/ASTMatchFinder.cpp
parent74b8f4cbdf62b0b6944ab109782f633733a67e98 (diff)
downloadbcm5719-llvm-d1ac50ecaa07ffd6c4b56919697e36cd642b72b4.tar.gz
bcm5719-llvm-d1ac50ecaa07ffd6c4b56919697e36cd642b72b4.zip
ASTMatchers: Keep AllCallbacks in a set instead of a vector
AllCallbacks is currently only used to call onStartOfTranslationUnit and onEndOfTranslationUnit on them. In this (and any other scenario I can come up with), it is important (or at least better) not to have duplicates in this container. E.g. currently onEndOfTranslationUnit is called repeatedly on the same callback for every matcher that is registered with it. llvm-svn: 249598
Diffstat (limited to 'clang/lib/ASTMatchers/ASTMatchFinder.cpp')
-rw-r--r--clang/lib/ASTMatchers/ASTMatchFinder.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/clang/lib/ASTMatchers/ASTMatchFinder.cpp b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
index e3b666ef42a..8807b13c5ed 100644
--- a/clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -913,37 +913,37 @@ MatchFinder::~MatchFinder() {}
void MatchFinder::addMatcher(const DeclarationMatcher &NodeMatch,
MatchCallback *Action) {
Matchers.DeclOrStmt.emplace_back(NodeMatch, Action);
- Matchers.AllCallbacks.push_back(Action);
+ Matchers.AllCallbacks.insert(Action);
}
void MatchFinder::addMatcher(const TypeMatcher &NodeMatch,
MatchCallback *Action) {
Matchers.Type.emplace_back(NodeMatch, Action);
- Matchers.AllCallbacks.push_back(Action);
+ Matchers.AllCallbacks.insert(Action);
}
void MatchFinder::addMatcher(const StatementMatcher &NodeMatch,
MatchCallback *Action) {
Matchers.DeclOrStmt.emplace_back(NodeMatch, Action);
- Matchers.AllCallbacks.push_back(Action);
+ Matchers.AllCallbacks.insert(Action);
}
void MatchFinder::addMatcher(const NestedNameSpecifierMatcher &NodeMatch,
MatchCallback *Action) {
Matchers.NestedNameSpecifier.emplace_back(NodeMatch, Action);
- Matchers.AllCallbacks.push_back(Action);
+ Matchers.AllCallbacks.insert(Action);
}
void MatchFinder::addMatcher(const NestedNameSpecifierLocMatcher &NodeMatch,
MatchCallback *Action) {
Matchers.NestedNameSpecifierLoc.emplace_back(NodeMatch, Action);
- Matchers.AllCallbacks.push_back(Action);
+ Matchers.AllCallbacks.insert(Action);
}
void MatchFinder::addMatcher(const TypeLocMatcher &NodeMatch,
MatchCallback *Action) {
Matchers.TypeLoc.emplace_back(NodeMatch, Action);
- Matchers.AllCallbacks.push_back(Action);
+ Matchers.AllCallbacks.insert(Action);
}
bool MatchFinder::addDynamicMatcher(const internal::DynTypedMatcher &NodeMatch,
OpenPOWER on IntegriCloud