summaryrefslogtreecommitdiffstats
path: root/clang/lib/ASTMatchers/ASTMatchFinder.cpp
diff options
context:
space:
mode:
authorManuel Klimek <klimek@google.com>2013-05-14 09:13:00 +0000
committerManuel Klimek <klimek@google.com>2013-05-14 09:13:00 +0000
commit24db0f0afd425fdb0854d3d6a6e04f87c76dd27f (patch)
treec779aa13b2fe7edaf54839f2dc7f074e06818e70 /clang/lib/ASTMatchers/ASTMatchFinder.cpp
parent5ecb5fd7b229005695daa5a8cbfd72aa81838d5c (diff)
downloadbcm5719-llvm-24db0f0afd425fdb0854d3d6a6e04f87c76dd27f.tar.gz
bcm5719-llvm-24db0f0afd425fdb0854d3d6a6e04f87c76dd27f.zip
First revision of the dynamic ASTMatcher library.
This library supports all the features of the compile-time based ASTMatcher library, but allows the user to specify and construct the matchers at runtime. It contains the following modules: - A variant type, to be used by the matcher factory. - A registry, where the matchers are indexed by name and have a factory method with a generic signature. - A simple matcher expression parser, that can be used to convert a matcher expression string into actual matchers that can be used with the AST at runtime. Many features where omitted from this first revision to simplify this code review. The main ideas are still represented in this change and it already has support working use cases. Things that are missing: - Support for polymorphic matchers. These requires supporting code in the registry, the marshallers and the variant type. - Support for numbers, char and bool arguments to the matchers. This requires supporting code in the parser and the variant type. - A command line program putting everything together and providing an already functional tool. Patch by Samuel Benzaquen. llvm-svn: 181768
Diffstat (limited to 'clang/lib/ASTMatchers/ASTMatchFinder.cpp')
-rw-r--r--clang/lib/ASTMatchers/ASTMatchFinder.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/ASTMatchers/ASTMatchFinder.cpp b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
index 6ebd736e3ce..eccc9cd4d37 100644
--- a/clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -744,6 +744,14 @@ void MatchFinder::addMatcher(const TypeLocMatcher &NodeMatch,
new TypeLocMatcher(NodeMatch), Action));
}
+bool MatchFinder::addDynamicMatcher(const internal::DynTypedMatcher &NodeMatch,
+ MatchCallback *Action) {
+ MatcherCallbackPairs.push_back(std::make_pair(NodeMatch.clone(), Action));
+ // TODO: Do runtime type checking to make sure the matcher is one of the valid
+ // top-level matchers.
+ return true;
+}
+
ASTConsumer *MatchFinder::newASTConsumer() {
return new internal::MatchASTConsumer(&MatcherCallbackPairs, ParsingDone);
}
OpenPOWER on IntegriCloud