File indexing completed on 2026-05-10 08:37:11
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_CLANG_TOOLING_REFACTORING_REFACTORINGOPTIONS_H
0010 #define LLVM_CLANG_TOOLING_REFACTORING_REFACTORINGOPTIONS_H
0011
0012 #include "clang/Basic/LLVM.h"
0013 #include "clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h"
0014 #include "clang/Tooling/Refactoring/RefactoringOption.h"
0015 #include "clang/Tooling/Refactoring/RefactoringOptionVisitor.h"
0016 #include "llvm/Support/Error.h"
0017 #include <optional>
0018 #include <type_traits>
0019
0020 namespace clang {
0021 namespace tooling {
0022
0023
0024 template <typename T,
0025 typename = std::enable_if_t<traits::IsValidOptionType<T>::value>>
0026 class OptionalRefactoringOption : public RefactoringOption {
0027 public:
0028 void passToVisitor(RefactoringOptionVisitor &Visitor) final {
0029 Visitor.visit(*this, Value);
0030 }
0031
0032 bool isRequired() const override { return false; }
0033
0034 using ValueType = std::optional<T>;
0035
0036 const ValueType &getValue() const { return Value; }
0037
0038 protected:
0039 std::optional<T> Value;
0040 };
0041
0042
0043 template <typename T,
0044 typename = std::enable_if_t<traits::IsValidOptionType<T>::value>>
0045 class RequiredRefactoringOption : public OptionalRefactoringOption<T> {
0046 public:
0047 using ValueType = T;
0048
0049 const ValueType &getValue() const {
0050 return *OptionalRefactoringOption<T>::Value;
0051 }
0052 bool isRequired() const final { return true; }
0053 };
0054
0055 }
0056 }
0057
0058 #endif