diff options
-rw-r--r-- | clang/include/clang/ASTMatchers/ASTMatchFinder.h | 3 | ||||
-rw-r--r-- | clang/lib/ASTMatchers/ASTMatchFinder.cpp | 12 |
2 files changed, 8 insertions, 7 deletions
diff --git a/clang/include/clang/ASTMatchers/ASTMatchFinder.h b/clang/include/clang/ASTMatchers/ASTMatchFinder.h index ce2674e442d..92ec92c299c 100644 --- a/clang/include/clang/ASTMatchers/ASTMatchFinder.h +++ b/clang/include/clang/ASTMatchers/ASTMatchFinder.h @@ -42,6 +42,7 @@ #define LLVM_CLANG_ASTMATCHERS_ASTMATCHFINDER_H #include "clang/ASTMatchers/ASTMatchers.h" +#include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/StringMap.h" #include "llvm/Support/Timer.h" @@ -208,7 +209,7 @@ public: NestedNameSpecifierLoc; std::vector<std::pair<TypeLocMatcher, MatchCallback *>> TypeLoc; /// \brief All the callbacks in one container to simplify iteration. - std::vector<MatchCallback *> AllCallbacks; + llvm::SmallPtrSet<MatchCallback *, 16> AllCallbacks; }; private: 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, |