Go to the documentation of this file.
18 #ifndef LLVM_CLANG_TOOLING_CORE_REPLACEMENT_H
19 #define LLVM_CLANG_TOOLING_CORE_REPLACEMENT_H
23 #include "llvm/ADT/Optional.h"
24 #include "llvm/ADT/StringRef.h"
25 #include "llvm/Support/Compiler.h"
26 #include "llvm/Support/Error.h"
27 #include "llvm/Support/raw_ostream.h"
31 #include <system_error>
59 return Offset + Length > RHS.Offset && Offset < RHS.Offset + RHS.Length;
64 return RHS.Offset >= Offset &&
65 (RHS.Offset + RHS.Length) <= (Offset + Length);
95 StringRef ReplacementText);
100 unsigned Length, StringRef ReplacementText);
104 StringRef ReplacementText,
108 template <
typename Node>
110 StringRef ReplacementText,
134 unsigned Length, StringRef ReplacementText);
137 StringRef ReplacementText,
141 Range ReplacementRange;
160 : Err(Err), ExistingReplacement(
std::move(Existing)) {}
165 : Err(Err), NewReplacement(
std::move(New)),
166 ExistingReplacement(
std::move(Existing)) {}
170 void log(raw_ostream &OS)
const override { OS <<
message(); }
177 return NewReplacement;
181 return ExistingReplacement;
186 std::error_code convertToErrorCode()
const override {
187 return llvm::inconvertibleErrorCode();
201 bool operator<(
const Replacement &LHS,
const Replacement &RHS);
204 bool operator==(
const Replacement &LHS,
const Replacement &RHS);
211 using ReplacementsImpl = std::set<Replacement>;
272 unsigned size()
const {
return Replaces.size(); }
276 bool empty()
const {
return Replaces.empty(); }
287 return Replaces == RHS.Replaces;
296 Replacement getReplacementInChangedCode(
const Replacement &R)
const;
308 mergeIfOrderIndependent(
const Replacement &R)
const;
310 ReplacementsImpl Replaces;
329 const Replacements &Replaces);
349 const std::vector<Range> &Ranges);
356 const std::map<std::string, Replacements> &FileToReplaces);
358 template <
typename Node>
360 const Node &NodeToReplace, StringRef ReplacementText,
364 setFromSourceRange(Sources,
Range, ReplacementText, LangOpts);
371 #endif // LLVM_CLANG_TOOLING_CORE_REPLACEMENT_H
Encodes a location in the source.
This class handles loading and caching of source files into memory.
static CharSourceRange getTokenRange(SourceRange R)
Represents a character-granular source range.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Implements support for file system lookup, file system caching, and directory search management.
Rewriter - This is the main interface to the rewrite buffers.