1259701Sdim//===--- Registry.h - Matcher registry -----*- C++ -*-===//
2259701Sdim//
3259701Sdim//                     The LLVM Compiler Infrastructure
4259701Sdim//
5259701Sdim// This file is distributed under the University of Illinois Open Source
6259701Sdim// License. See LICENSE.TXT for details.
7259701Sdim//
8259701Sdim//===----------------------------------------------------------------------===//
9259701Sdim///
10259701Sdim/// \file
11259701Sdim/// \brief Registry of all known matchers.
12259701Sdim///
13259701Sdim/// The registry provides a generic interface to construct any matcher by name.
14259701Sdim///
15259701Sdim//===----------------------------------------------------------------------===//
16259701Sdim
17259701Sdim#ifndef LLVM_CLANG_AST_MATCHERS_DYNAMIC_REGISTRY_H
18259701Sdim#define LLVM_CLANG_AST_MATCHERS_DYNAMIC_REGISTRY_H
19259701Sdim
20259701Sdim#include "clang/ASTMatchers/Dynamic/Diagnostics.h"
21259701Sdim#include "clang/ASTMatchers/Dynamic/VariantValue.h"
22259701Sdim#include "clang/Basic/LLVM.h"
23259701Sdim#include "llvm/ADT/ArrayRef.h"
24259701Sdim#include "llvm/ADT/StringRef.h"
25259701Sdim
26259701Sdimnamespace clang {
27259701Sdimnamespace ast_matchers {
28259701Sdimnamespace dynamic {
29259701Sdim
30259701Sdimclass Registry {
31259701Sdimpublic:
32259701Sdim  /// \brief Construct a matcher from the registry by name.
33259701Sdim  ///
34259701Sdim  /// Consult the registry of known matchers and construct the appropriate
35259701Sdim  /// matcher by name.
36259701Sdim  ///
37259701Sdim  /// \param MatcherName The name of the matcher to instantiate.
38259701Sdim  ///
39259701Sdim  /// \param NameRange The location of the name in the matcher source.
40259701Sdim  ///   Useful for error reporting.
41259701Sdim  ///
42259701Sdim  /// \param Args The argument list for the matcher. The number and types of the
43259701Sdim  ///   values must be valid for the matcher requested. Otherwise, the function
44259701Sdim  ///   will return an error.
45259701Sdim  ///
46259701Sdim  /// \return The matcher object constructed if no error was found.
47259701Sdim  ///   A null matcher if the matcher is not found, or if the number of
48259701Sdim  ///   arguments or argument types do not match the signature.
49259701Sdim  ///   In that case \c Error will contain the description of the error.
50259701Sdim  static VariantMatcher constructMatcher(StringRef MatcherName,
51259701Sdim                                         const SourceRange &NameRange,
52259701Sdim                                         ArrayRef<ParserValue> Args,
53259701Sdim                                         Diagnostics *Error);
54259701Sdim
55259701Sdim  /// \brief Construct a matcher from the registry and bind it.
56259701Sdim  ///
57259701Sdim  /// Similar the \c constructMatcher() above, but it then tries to bind the
58259701Sdim  /// matcher to the specified \c BindID.
59259701Sdim  /// If the matcher is not bindable, it sets an error in \c Error and returns
60259701Sdim  /// a null matcher.
61259701Sdim  static VariantMatcher constructBoundMatcher(StringRef MatcherName,
62259701Sdim                                              const SourceRange &NameRange,
63259701Sdim                                              StringRef BindID,
64259701Sdim                                              ArrayRef<ParserValue> Args,
65259701Sdim                                              Diagnostics *Error);
66259701Sdim
67259701Sdimprivate:
68259701Sdim  Registry() LLVM_DELETED_FUNCTION;
69259701Sdim};
70259701Sdim
71259701Sdim}  // namespace dynamic
72259701Sdim}  // namespace ast_matchers
73259701Sdim}  // namespace clang
74259701Sdim
75259701Sdim#endif  // LLVM_CLANG_AST_MATCHERS_DYNAMIC_REGISTRY_H
76