/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/include/clang/Tooling/Refactoring/RefactoringOptionVisitor.h
Line | Count | Source |
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_REFACTORING_REFACTORINGOPTIONVISITOR_H |
10 | | #define LLVM_CLANG_TOOLING_REFACTORING_REFACTORINGOPTIONVISITOR_H |
11 | | |
12 | | #include "clang/Basic/LLVM.h" |
13 | | #include <optional> |
14 | | #include <type_traits> |
15 | | |
16 | | namespace clang { |
17 | | namespace tooling { |
18 | | |
19 | | class RefactoringOption; |
20 | | |
21 | | /// An interface that declares functions that handle different refactoring |
22 | | /// option types. |
23 | | /// |
24 | | /// A valid refactoring option type must have a corresponding \c visit |
25 | | /// declaration in this interface. |
26 | | class RefactoringOptionVisitor { |
27 | | public: |
28 | 87 | virtual ~RefactoringOptionVisitor() {} |
29 | | |
30 | | virtual void visit(const RefactoringOption &Opt, |
31 | | std::optional<std::string> &Value) = 0; |
32 | | }; |
33 | | |
34 | | namespace traits { |
35 | | namespace internal { |
36 | | |
37 | | template <typename T> struct HasHandle { |
38 | | private: |
39 | | template <typename ClassT> |
40 | | static auto check(ClassT *) -> typename std::is_same< |
41 | | decltype(std::declval<RefactoringOptionVisitor>().visit( |
42 | | std::declval<RefactoringOption>(), |
43 | | *std::declval<std::optional<T> *>())), |
44 | | void>::type; |
45 | | |
46 | | template <typename> static std::false_type check(...); |
47 | | |
48 | | public: |
49 | | using Type = decltype(check<RefactoringOptionVisitor>(nullptr)); |
50 | | }; |
51 | | |
52 | | } // end namespace internal |
53 | | |
54 | | /// A type trait that returns true iff the given type is a type that can be |
55 | | /// stored in a refactoring option. |
56 | | template <typename T> |
57 | | struct IsValidOptionType : internal::HasHandle<T>::Type {}; |
58 | | |
59 | | } // end namespace traits |
60 | | } // end namespace tooling |
61 | | } // end namespace clang |
62 | | |
63 | | #endif // LLVM_CLANG_TOOLING_REFACTORING_REFACTORINGOPTIONVISITOR_H |