19 #ifndef LLVM_CLANG_TOOLING_CORE_REPLACEMENT_H
20 #define LLVM_CLANG_TOOLING_CORE_REPLACEMENT_H
25 #include "llvm/ADT/Optional.h"
26 #include "llvm/ADT/StringRef.h"
27 #include "llvm/Support/Error.h"
28 #include "llvm/Support/raw_ostream.h"
32 #include <system_error>
45 Range(
unsigned Offset,
unsigned Length) : Offset(Offset), Length(Length) {}
57 return Offset + Length > RHS.Offset &&
Offset < RHS.Offset + RHS.Length;
62 return RHS.Offset >=
Offset &&
63 (RHS.Offset + RHS.Length) <= (
Offset + Length);
93 StringRef ReplacementText);
98 unsigned Length, StringRef ReplacementText);
102 StringRef ReplacementText,
106 template <
typename Node>
108 StringRef ReplacementText,
132 unsigned Length, StringRef ReplacementText);
135 StringRef ReplacementText,
138 std::string FilePath;
139 Range ReplacementRange;
140 std::string ReplacementText;
158 : Err(Err), ExistingReplacement(std::move(Existing)) {}
163 : Err(Err), NewReplacement(std::move(New)),
164 ExistingReplacement(std::move(Existing)) {}
166 std::string
message()
const override;
168 void log(raw_ostream &OS)
const override { OS <<
message(); }
175 return NewReplacement;
179 return ExistingReplacement;
184 std::error_code convertToErrorCode()
const override {
185 return llvm::inconvertibleErrorCode();
207 typedef std::set<Replacement> ReplacementsImpl;
268 unsigned size()
const {
return Replaces.size(); }
272 bool empty()
const {
return Replaces.empty(); }
283 return Replaces == RHS.Replaces;
289 : Replaces(Begin, End) {}
305 mergeIfOrderIndependent(
const Replacement &R)
const;
307 ReplacementsImpl Replaces;
326 const Replacements &Replaces);
345 const std::vector<Range> &Ranges);
352 const std::map<std::string, Replacements> &FileToReplaces);
354 template <
typename Node>
356 const Node &NodeToReplace, StringRef ReplacementText,
360 setFromSourceRange(Sources, Range, ReplacementText, LangOpts);
366 #endif // LLVM_CLANG_TOOLING_CORE_REPLACEMENT_H
Implements support for file system lookup, file system caching, and directory search management...
Defines the clang::FileManager interface and associated types.
static CharSourceRange getTokenRange(SourceRange R)
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Defines the clang::LangOptions interface.
Represents a character-granular source range.
Encodes a location in the source.
ast_type_traits::DynTypedNode Node
Rewriter - This is the main interface to the rewrite buffers.
Defines the clang::SourceLocation class and associated facilities.
This class handles loading and caching of source files into memory.