summaryrefslogtreecommitdiff
path: root/clang/include/clang/Tooling/Refactoring
diff options
context:
space:
mode:
Diffstat (limited to 'clang/include/clang/Tooling/Refactoring')
-rw-r--r--clang/include/clang/Tooling/Refactoring/ASTSelection.h6
-rw-r--r--clang/include/clang/Tooling/Refactoring/AtomicChange.h14
-rw-r--r--clang/include/clang/Tooling/Refactoring/RefactoringOptions.h8
3 files changed, 20 insertions, 8 deletions
diff --git a/clang/include/clang/Tooling/Refactoring/ASTSelection.h b/clang/include/clang/Tooling/Refactoring/ASTSelection.h
index 9122b5c73c98a..239be36012c3d 100644
--- a/clang/include/clang/Tooling/Refactoring/ASTSelection.h
+++ b/clang/include/clang/Tooling/Refactoring/ASTSelection.h
@@ -13,6 +13,7 @@
#include "clang/AST/Stmt.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/SourceLocation.h"
+#include "llvm/Support/raw_ostream.h"
#include <vector>
namespace clang {
@@ -48,12 +49,11 @@ enum class SourceSelectionKind {
/// actually be selected, e.g. a statement in macro whose child is in a macro
/// argument.
struct SelectedASTNode {
- ast_type_traits::DynTypedNode Node;
+ DynTypedNode Node;
SourceSelectionKind SelectionKind;
std::vector<SelectedASTNode> Children;
- SelectedASTNode(const ast_type_traits::DynTypedNode &Node,
- SourceSelectionKind SelectionKind)
+ SelectedASTNode(const DynTypedNode &Node, SourceSelectionKind SelectionKind)
: Node(Node), SelectionKind(SelectionKind) {}
SelectedASTNode(SelectedASTNode &&) = default;
SelectedASTNode &operator=(SelectedASTNode &&) = default;
diff --git a/clang/include/clang/Tooling/Refactoring/AtomicChange.h b/clang/include/clang/Tooling/Refactoring/AtomicChange.h
index 32e4624fc8e78..f1034a3d05794 100644
--- a/clang/include/clang/Tooling/Refactoring/AtomicChange.h
+++ b/clang/include/clang/Tooling/Refactoring/AtomicChange.h
@@ -17,6 +17,7 @@
#include "clang/Basic/SourceManager.h"
#include "clang/Format/Format.h"
#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/Any.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Error.h"
@@ -41,6 +42,9 @@ public:
/// is being changed, e.g. the call to a refactored method.
AtomicChange(const SourceManager &SM, SourceLocation KeyPosition);
+ AtomicChange(const SourceManager &SM, SourceLocation KeyPosition,
+ llvm::Any Metadata);
+
/// Creates an atomic change for \p FilePath with a customized key.
AtomicChange(llvm::StringRef FilePath, llvm::StringRef Key)
: Key(Key), FilePath(FilePath) {}
@@ -70,7 +74,7 @@ public:
/// conflicts among replacements, use this to set an error description.
/// Thereby, places that cannot be fixed automatically can be gathered when
/// applying changes.
- void setError(llvm::StringRef Error) { this->Error = Error; }
+ void setError(llvm::StringRef Error) { this->Error = std::string(Error); }
/// Returns whether an error has been set on this list.
bool hasError() const { return !Error.empty(); }
@@ -120,6 +124,8 @@ public:
return RemovedHeaders;
}
+ const llvm::Any &getMetadata() const { return Metadata; }
+
private:
AtomicChange() {}
@@ -135,6 +141,12 @@ private:
std::vector<std::string> InsertedHeaders;
std::vector<std::string> RemovedHeaders;
tooling::Replacements Replaces;
+
+ // This field stores metadata which is ignored for the purposes of applying
+ // edits to source, but may be useful for other consumers of AtomicChanges. In
+ // particular, consumers can use this to direct how they want to consume each
+ // edit.
+ llvm::Any Metadata;
};
using AtomicChanges = std::vector<AtomicChange>;
diff --git a/clang/include/clang/Tooling/Refactoring/RefactoringOptions.h b/clang/include/clang/Tooling/Refactoring/RefactoringOptions.h
index f25f526e146cc..84122b111ee17 100644
--- a/clang/include/clang/Tooling/Refactoring/RefactoringOptions.h
+++ b/clang/include/clang/Tooling/Refactoring/RefactoringOptions.h
@@ -20,8 +20,8 @@ namespace clang {
namespace tooling {
/// A refactoring option that stores a value of type \c T.
-template <typename T, typename = typename std::enable_if<
- traits::IsValidOptionType<T>::value>::type>
+template <typename T,
+ typename = std::enable_if_t<traits::IsValidOptionType<T>::value>>
class OptionalRefactoringOption : public RefactoringOption {
public:
void passToVisitor(RefactoringOptionVisitor &Visitor) final override {
@@ -39,8 +39,8 @@ protected:
};
/// A required refactoring option that stores a value of type \c T.
-template <typename T, typename = typename std::enable_if<
- traits::IsValidOptionType<T>::value>::type>
+template <typename T,
+ typename = std::enable_if_t<traits::IsValidOptionType<T>::value>>
class RequiredRefactoringOption : public OptionalRefactoringOption<T> {
public:
using ValueType = T;