clang  14.0.0git
RefactoringOptions.h
Go to the documentation of this file.
1 //===--- RefactoringOptions.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_OPTIONS_H
10 #define LLVM_CLANG_TOOLING_REFACTOR_REFACTORING_OPTIONS_H
11 
12 #include "clang/Basic/LLVM.h"
16 #include "llvm/Support/Error.h"
17 #include <type_traits>
18 
19 namespace clang {
20 namespace tooling {
21 
22 /// A refactoring option that stores a value of type \c T.
23 template <typename T,
24  typename = std::enable_if_t<traits::IsValidOptionType<T>::value>>
26 public:
27  void passToVisitor(RefactoringOptionVisitor &Visitor) final override {
28  Visitor.visit(*this, Value);
29  }
30 
31  bool isRequired() const override { return false; }
32 
34 
35  const ValueType &getValue() const { return Value; }
36 
37 protected:
39 };
40 
41 /// A required refactoring option that stores a value of type \c T.
42 template <typename T,
43  typename = std::enable_if_t<traits::IsValidOptionType<T>::value>>
45 public:
46  using ValueType = T;
47 
48  const ValueType &getValue() const {
50  }
51  bool isRequired() const final override { return true; }
52 };
53 
54 } // end namespace tooling
55 } // end namespace clang
56 
57 #endif // LLVM_CLANG_TOOLING_REFACTOR_REFACTORING_OPTIONS_H
clang::tooling::RequiredRefactoringOption
A required refactoring option that stores a value of type T.
Definition: RefactoringOptions.h:44
clang::tooling::OptionalRefactoringOption::isRequired
bool isRequired() const override
True when this option must be specified before invoking the refactoring action.
Definition: RefactoringOptions.h:31
clang::tooling::RequiredRefactoringOption::isRequired
bool isRequired() const final override
True when this option must be specified before invoking the refactoring action.
Definition: RefactoringOptions.h:51
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::tooling::OptionalRefactoringOption
A refactoring option that stores a value of type T.
Definition: RefactoringOptions.h:25
RefactoringOption.h
llvm::Optional
Definition: LLVM.h:40
clang::tooling::RequiredRefactoringOption::getValue
const ValueType & getValue() const
Definition: RefactoringOptions.h:48
clang::tooling::OptionalRefactoringOption::passToVisitor
void passToVisitor(RefactoringOptionVisitor &Visitor) final override
Invokes the visit method in the option consumer that's appropriate for the option's value type.
Definition: RefactoringOptions.h:27
clang::tooling::OptionalRefactoringOption< T >::ValueType
Optional< T > ValueType
Definition: RefactoringOptions.h:33
clang::tooling::OptionalRefactoringOption::getValue
const ValueType & getValue() const
Definition: RefactoringOptions.h:35
RefactoringOptionVisitor.h
RefactoringActionRuleRequirements.h
Value
Value
Definition: UninitializedValues.cpp:102
LLVM.h
clang::tooling::RequiredRefactoringOption::ValueType
T ValueType
Definition: RefactoringOptions.h:46
clang
Definition: CalledOnceCheck.h:17
clang::tooling::OptionalRefactoringOption::Value
Optional< T > Value
Definition: RefactoringOptions.h:38
clang::tooling::RefactoringOptionVisitor
An interface that declares functions that handle different refactoring option types.
Definition: RefactoringOptionVisitor.h:25