clang: lib/Tooling/Refactoring.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
21
24
27 std::shared_ptr PCHContainerOps)
28 : ClangTool(Compilations, SourcePaths, std::move(PCHContainerOps)) {}
29
31 return FileToReplaces;
32}
33
35 if (int Result = run(ActionFactory)) {
37 }
38
43 &DiagnosticPrinter, false);
46
48 llvm::errs() << "Skipped some replacements.\n";
49 }
50
51 return saveRewrittenFiles(Rewrite);
52}
53
57 Rewrite.getSourceMgr().getFileManager(), FileToReplaces))
60}
61
62int RefactoringTool::saveRewrittenFiles(Rewriter &Rewrite) {
63 return Rewrite.overwriteChangedFiles() ? 1 : 0;
64}
65
67 const std::map<std::string, Replacements> &FileToReplaces,
71
74 Rewrite.getSourceMgr().getFileManager(), FileToReplaces)) {
75 const std::string &FilePath = FileAndReplaces.first;
76 auto &CurReplaces = FileAndReplaces.second;
77
80 StringRef Code = SM.getBufferData(ID);
81
83 if (!CurStyle) {
84 llvm::errs() << llvm::toString(CurStyle.takeError()) << "\n";
85 return false;
86 }
87
88 auto NewReplacements =
90 if (!NewReplacements) {
91 llvm::errs() << llvm::toString(NewReplacements.takeError()) << "\n";
92 return false;
93 }
95 }
97}
98
99}
100}
Defines the clang::FileManager interface and associated types.
Various functions to configurably format source code.
Defines the SourceManager interface.
static llvm::IntrusiveRefCntPtr< DiagnosticIDs > create()
Options for controlling the compiler diagnostics engine.
Concrete class used by the front-end to report problems and issues.
A reference to a FileEntry that includes the name of the file as it was accessed by the FileManager's...
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Implements support for file system lookup, file system caching, and directory search management.
llvm::Expected< FileEntryRef > getFileRef(StringRef Filename, bool OpenFile=false, bool CacheFailure=true, bool IsText=true)
Lookup, cache, and verify the specified file (real or virtual).
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Rewriter - This is the main interface to the rewrite buffers.
This class handles loading and caching of source files into memory.
Expected< FormatStyle > getStyle(StringRef StyleName, StringRef FileName, StringRef FallbackStyleName, StringRef Code, llvm::vfs::FileSystem *FS, bool AllowUnknownOptions, llvm::SourceMgr::DiagHandlerTy DiagHandler)
Expected< tooling::Replacements > formatReplacements(StringRef Code, const tooling::Replacements &Replaces, const FormatStyle &Style)
The JSON file list parser is used to communicate input to InstallAPI.
@ Rewrite
We are substituting template parameters for (typically) other template parameters in order to rewrite...
@ Result
The result type of a method or function.