Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:37:11

0001 //===--- RefactoringOptionVisitor.h - Clang refactoring library -----------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLVM_CLANG_TOOLING_REFACTORING_REFACTORINGOPTIONVISITOR_H
0010 #define LLVM_CLANG_TOOLING_REFACTORING_REFACTORINGOPTIONVISITOR_H
0011 
0012 #include "clang/Basic/LLVM.h"
0013 #include <optional>
0014 #include <type_traits>
0015 
0016 namespace clang {
0017 namespace tooling {
0018 
0019 class RefactoringOption;
0020 
0021 /// An interface that declares functions that handle different refactoring
0022 /// option types.
0023 ///
0024 /// A valid refactoring option type must have a corresponding \c visit
0025 /// declaration in this interface.
0026 class RefactoringOptionVisitor {
0027 public:
0028   virtual ~RefactoringOptionVisitor() {}
0029 
0030   virtual void visit(const RefactoringOption &Opt,
0031                      std::optional<std::string> &Value) = 0;
0032 };
0033 
0034 namespace traits {
0035 namespace internal {
0036 
0037 template <typename T> struct HasHandle {
0038 private:
0039   template <typename ClassT>
0040   static auto check(ClassT *) -> typename std::is_same<
0041       decltype(std::declval<RefactoringOptionVisitor>().visit(
0042           std::declval<RefactoringOption>(),
0043           *std::declval<std::optional<T> *>())),
0044       void>::type;
0045 
0046   template <typename> static std::false_type check(...);
0047 
0048 public:
0049   using Type = decltype(check<RefactoringOptionVisitor>(nullptr));
0050 };
0051 
0052 } // end namespace internal
0053 
0054 /// A type trait that returns true iff the given type is a type that can be
0055 /// stored in a refactoring option.
0056 template <typename T>
0057 struct IsValidOptionType : internal::HasHandle<T>::Type {};
0058 
0059 } // end namespace traits
0060 } // end namespace tooling
0061 } // end namespace clang
0062 
0063 #endif // LLVM_CLANG_TOOLING_REFACTORING_REFACTORINGOPTIONVISITOR_H