diff options
Diffstat (limited to 'clang/include/clang/Tooling/Refactoring/AtomicChange.h')
-rw-r--r-- | clang/include/clang/Tooling/Refactoring/AtomicChange.h | 14 |
1 files changed, 13 insertions, 1 deletions
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>; |