21 #include "llvm/Support/Path.h" 22 #include "llvm/Support/raw_os_ostream.h" 29 std::shared_ptr<PCHContainerOperations> PCHContainerOps)
30 :
ClangTool(Compilations, SourcePaths,
std::move(PCHContainerOps)) {}
33 return FileToReplaces;
37 if (
int Result =
run(ActionFactory)) {
46 &*DiagOpts, &DiagnosticPrinter,
false);
48 Rewriter Rewrite(Sources, DefaultLangOptions);
51 llvm::errs() <<
"Skipped some replacements.\n";
54 return saveRewrittenFiles(Rewrite);
65 int RefactoringTool::saveRewrittenFiles(
Rewriter &Rewrite) {
70 const std::map<std::string, Replacements> &FileToReplaces,
78 const std::string &FilePath = FileAndReplaces.first;
79 auto &CurReplaces = FileAndReplaces.second;
91 auto NewReplacements =
93 if (!NewReplacements) {
94 llvm::errs() <<
llvm::toString(NewReplacements.takeError()) <<
"\n";
Implements support for file system lookup, file system caching, and directory search management...
Defines the clang::FileManager interface and associated types.
Defines the SourceManager interface.
StringRef getBufferData(FileID FID, bool *Invalid=nullptr) const
Return a StringRef to the source buffer data for the specified FileID.
FileManager & getFileManager() const
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
SourceManager & getSourceMgr() const
Concrete class used by the front-end to report problems and issues.
const FileEntry * getFile(StringRef Filename, bool OpenFile=false, bool CacheFailure=true)
Lookup, cache, and verify the specified file (real or virtual).
FileID getOrCreateFileID(const FileEntry *SourceFile, SrcMgr::CharacteristicKind FileCharacter)
Get the FileID for SourceFile if it exists.
bool overwriteChangedFiles()
overwriteChangedFiles - Save all changed files to disk.
Options for controlling the compiler diagnostics engine.
Cached information about one file (either on disk or in the virtual file system). ...
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Dataflow Directional Tag Classes.
Used for handling and querying diagnostic IDs.
Rewriter - This is the main interface to the rewrite buffers.
This class handles loading and caching of source files into memory.