clang  14.0.0git
RefactoringOptionVisitor.h
Go to the documentation of this file.
1 //===--- RefactoringOptionVisitor.h - Clang refactoring library -----------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_CLANG_TOOLING_REFACTOR_REFACTORING_OPTION_VISITOR_H
10 #define LLVM_CLANG_TOOLING_REFACTOR_REFACTORING_OPTION_VISITOR_H
11 
12 #include "clang/Basic/LLVM.h"
13 #include <type_traits>
14 
15 namespace clang {
16 namespace tooling {
17 
18 class RefactoringOption;
19 
20 /// An interface that declares functions that handle different refactoring
21 /// option types.
22 ///
23 /// A valid refactoring option type must have a corresponding \c visit
24 /// declaration in this interface.
26 public:
28 
29  virtual void visit(const RefactoringOption &Opt,
31 };
32 
33 namespace traits {
34 namespace internal {
35 
36 template <typename T> struct HasHandle {
37 private:
38  template <typename ClassT>
39  static auto check(ClassT *) -> typename std::is_same<
40  decltype(std::declval<RefactoringOptionVisitor>().visit(
41  std::declval<RefactoringOption>(), *std::declval<Optional<T> *>())),
42  void>::type;
43 
44  template <typename> static std::false_type check(...);
45 
46 public:
47  using Type = decltype(check<RefactoringOptionVisitor>(nullptr));
48 };
49 
50 } // end namespace internal
51 
52 /// A type trait that returns true iff the given type is a type that can be
53 /// stored in a refactoring option.
54 template <typename T>
56 
57 } // end namespace traits
58 } // end namespace tooling
59 } // end namespace clang
60 
61 #endif // LLVM_CLANG_TOOLING_REFACTOR_REFACTORING_OPTION_VISITOR_H
clang::tooling::traits::internal::HasHandle
Definition: RefactoringOptionVisitor.h:36
clang::tooling::RefactoringOption
A refactoring option is an interface that describes a value that has an impact on the outcome of a re...
Definition: RefactoringOption.h:26
clang::ast_matchers::type
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Definition: ASTMatchersInternal.cpp:772
llvm::Optional< std::string >
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1490
clang::tooling::traits::IsValidOptionType
A type trait that returns true iff the given type is a type that can be stored in a refactoring optio...
Definition: RefactoringOptionVisitor.h:55
Value
Value
Definition: UninitializedValues.cpp:102
LLVM.h
clang::tooling::traits::internal::HasHandle::Type
decltype(check< RefactoringOptionVisitor >(nullptr)) Type
Definition: RefactoringOptionVisitor.h:47
clang::tooling::RefactoringOptionVisitor::~RefactoringOptionVisitor
virtual ~RefactoringOptionVisitor()
Definition: RefactoringOptionVisitor.h:27
clang
Definition: CalledOnceCheck.h:17
clang::tooling::RefactoringOptionVisitor
An interface that declares functions that handle different refactoring option types.
Definition: RefactoringOptionVisitor.h:25
clang::tooling::RefactoringOptionVisitor::visit
virtual void visit(const RefactoringOption &Opt, Optional< std::string > &Value)=0