16 #ifndef LLVM_CLANG_APPLYREPLACEMENTS_H
17 #define LLVM_CLANG_APPLYREPLACEMENTS_H
19 #include "clang/Tooling/Refactoring.h"
20 #include "llvm/ADT/StringMap.h"
21 #include "llvm/ADT/StringRef.h"
23 #include <system_error>
28 class DiagnosticsEngine;
41 typedef std::vector<clang::tooling::TranslationUnitReplacements>
48 typedef llvm::DenseMap<
const clang::FileEntry *,
49 std::vector<clang::tooling::Replacement>>
73 clang::DiagnosticsEngine &Diagnostics);
92 clang::SourceManager &
SM);
105 clang::Rewriter &Rewrites);
117 const std::vector<clang::tooling::Replacement> &Replacements);
123 bool writeFiles(
const clang::Rewriter &Rewrites);
135 clang::DiagnosticsEngine &Diagnostics);
140 #endif // LLVM_CLANG_APPLYREPLACEMENTS_H
llvm::DenseMap< const clang::FileEntry *, std::vector< clang::tooling::Replacement > > FileToReplacementsMap
Map mapping file name to Replacements targeting that file.
bool deleteReplacementFiles(const TUReplacementFiles &Files, clang::DiagnosticsEngine &Diagnostics)
Delete the replacement files.
std::vector< clang::tooling::TranslationUnitReplacements > TUReplacements
Collection of TranslationUnitReplacements.
bool applyReplacements(const FileToReplacementsMap &GroupedReplacements, clang::Rewriter &Rewrites)
Apply all replacements in GroupedReplacements.
std::error_code collectReplacementsFromDirectory(const llvm::StringRef Directory, TUReplacements &TUs, TUReplacementFiles &TURFiles, clang::DiagnosticsEngine &Diagnostics)
Recursively descends through a directory structure rooted at Directory and attempts to deserialize *...
bool writeFiles(const clang::Rewriter &Rewrites)
Write the contents of FileContents to disk.
static cl::opt< std::string > Directory(cl::Positional, cl::Required, cl::desc("<Search Root Directory>"))
std::vector< clang::tooling::Range > RangeVector
Collection of source ranges.
RangeVector calculateChangedRanges(const std::vector< clang::tooling::Replacement > &Replacements)
Given a collection of Replacements for a single file, produces a list of source ranges that enclose t...
std::vector< std::string > TUReplacementFiles
Collection of TranslationUnitReplacement files.
bool mergeAndDeduplicate(const TUReplacements &TUs, FileToReplacementsMap &GroupedReplacements, clang::SourceManager &SM)
Deduplicate, check for conflicts, and apply all Replacements stored in TUs.