16 #ifndef LLVM_CLANG_APPLYREPLACEMENTS_H
17 #define LLVM_CLANG_APPLYREPLACEMENTS_H
19 #include "clang/Tooling/Core/Diagnostic.h"
20 #include "clang/Tooling/Refactoring.h"
21 #include "llvm/ADT/StringMap.h"
22 #include "llvm/ADT/StringRef.h"
24 #include <system_error>
29 class DiagnosticsEngine;
42 typedef std::vector<clang::tooling::TranslationUnitReplacements>
TUReplacements;
48 typedef std::vector<clang::tooling::TranslationUnitDiagnostics>
TUDiagnostics;
51 typedef llvm::DenseMap<
const clang::FileEntry *,
52 std::vector<clang::tooling::Replacement>>
98 clang::SourceManager &
SM);
102 clang::SourceManager &
SM);
120 clang::Rewriter &Rewrites);
132 const std::vector<clang::tooling::Replacement> &Replacements);
138 bool writeFiles(
const clang::Rewriter &Rewrites);
150 clang::DiagnosticsEngine &Diagnostics);
155 #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.
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::error_code collectReplacementsFromDirectory(const llvm::StringRef Directory, TUReplacements &TUs, TUReplacementFiles &TUFiles, clang::DiagnosticsEngine &Diagnostics)
Recursively descends through a directory structure rooted at Directory and attempts to deserialize *...
std::vector< clang::tooling::TranslationUnitDiagnostics > TUDiagnostics
Collection of TranslationUniDiagnostics.
std::vector< std::string > TUReplacementFiles
Collection of TranslationUnitReplacement files.
bool applyAllReplacements(const std::vector< tooling::Replacement > &Replaces, Rewriter &Rewrite)
bool mergeAndDeduplicate(const TUReplacements &TUs, FileToReplacementsMap &GroupedReplacements, clang::SourceManager &SM)
Deduplicate, check for conflicts, and apply all Replacements stored in TUs.
static cl::opt< std::string > FormatStyle("format-style", cl::desc(R"(
Style for formatting code around applied fixes:
- 'none' (default) turns off formatting
- 'file' (literally 'file', not a placeholder)
uses .clang-format file in the closest parent
directory
- '{ <json> }' specifies options inline, e.g.
-format-style='{BasedOnStyle: llvm, IndentWidth: 8}'
- 'llvm', 'google', 'webkit', 'mozilla'
See clang-format documentation for the up-to-date
information about formatting styles and options.
This option overrides the 'FormatStyle` option in
.clang-tidy file, if any.
)"), cl::init("none"), cl::cat(ClangTidyCategory))