22 #include "llvm/Support/FileSystem.h"
23 #include "llvm/Support/Path.h"
24 #include "llvm/Support/raw_os_ostream.h"
31 std::shared_ptr<PCHContainerOperations> PCHContainerOps)
32 :
ClangTool(Compilations, SourcePaths, PCHContainerOps) {}
46 &*DiagOpts, &DiagnosticPrinter,
false);
48 Rewriter Rewrite(Sources, DefaultLangOptions);
51 llvm::errs() <<
"Skipped some replacements.\n";
54 return saveRewrittenFiles(Rewrite);
61 int RefactoringTool::saveRewrittenFiles(
Rewriter &Rewrite) {
73 for (
const auto &FileAndReplaces : FileToReplaces) {
74 const std::string &
FilePath = FileAndReplaces.first;
75 auto &CurReplaces = FileAndReplaces.second;
82 auto NewReplacements =
84 if (!NewReplacements) {
85 llvm::errs() <<
llvm::toString(NewReplacements.takeError()) <<
"\n";
Implements support for file system lookup, file system caching, and directory search management...
SourceManager & getSourceMgr() const
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.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
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.
FileManager & getFileManager() const
The result type of a method or function.
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...
Used for handling and querying diagnostic IDs.
std::string toString(const til::SExpr *E)
Rewriter - This is the main interface to the rewrite buffers.
This class handles loading and caching of source files into memory.