1 //===--- Registry.h - Matcher registry -----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// \brief Registry of all known matchers.
13 /// The registry provides a generic interface to construct any matcher by name.
15 //===----------------------------------------------------------------------===//
17 #ifndef LLVM_CLANG_AST_MATCHERS_DYNAMIC_REGISTRY_H
18 #define LLVM_CLANG_AST_MATCHERS_DYNAMIC_REGISTRY_H
20 #include "clang/ASTMatchers/Dynamic/Diagnostics.h"
21 #include "clang/ASTMatchers/Dynamic/VariantValue.h"
22 #include "clang/Basic/LLVM.h"
23 #include "llvm/ADT/ArrayRef.h"
24 #include "llvm/ADT/StringRef.h"
27 namespace ast_matchers {
32 /// \brief Construct a matcher from the registry by name.
34 /// Consult the registry of known matchers and construct the appropriate
37 /// \param MatcherName The name of the matcher to instantiate.
39 /// \param NameRange The location of the name in the matcher source.
40 /// Useful for error reporting.
42 /// \param Args The argument list for the matcher. The number and types of the
43 /// values must be valid for the matcher requested. Otherwise, the function
44 /// will return an error.
46 /// \return The matcher object constructed if no error was found.
47 /// A null matcher if the matcher is not found, or if the number of
48 /// arguments or argument types do not match the signature.
49 /// In that case \c Error will contain the description of the error.
50 static VariantMatcher constructMatcher(StringRef MatcherName,
51 const SourceRange &NameRange,
52 ArrayRef<ParserValue> Args,
55 /// \brief Construct a matcher from the registry and bind it.
57 /// Similar the \c constructMatcher() above, but it then tries to bind the
58 /// matcher to the specified \c BindID.
59 /// If the matcher is not bindable, it sets an error in \c Error and returns
61 static VariantMatcher constructBoundMatcher(StringRef MatcherName,
62 const SourceRange &NameRange,
64 ArrayRef<ParserValue> Args,
68 Registry() LLVM_DELETED_FUNCTION;
71 } // namespace dynamic
72 } // namespace ast_matchers
75 #endif // LLVM_CLANG_AST_MATCHERS_DYNAMIC_REGISTRY_H