27#include "llvm/ADT/SmallVector.h"
28#include "llvm/Support/Debug.h"
30#define DEBUG_TYPE "format-formatter"
45 llvm::errs() << Message <<
"\n";
55std::unique_ptr<Environment>
58 unsigned NextStartColumn,
unsigned LastStartColumn) {
59 auto Env = std::make_unique<Environment>(Code,
FileName, FirstStartColumn,
60 NextStartColumn, LastStartColumn);
62 Env->SM.getDiagnostics().setClient(&Diags,
false);
70 Env->SM.getBufferData(
Env->ID);
77 unsigned FirstStartColumn,
unsigned NextStartColumn,
78 unsigned LastStartColumn)
80 ID(VirtualSM->get().getMainFileID()), FirstStartColumn(FirstStartColumn),
81 NextStartColumn(NextStartColumn), LastStartColumn(LastStartColumn) {}
85 AffectedRangeMgr(
Env.getSourceManager(),
Env.getCharRanges()),
87 Encoding(encoding::detectEncoding(
88 Env.getSourceManager().getBufferData(
Env.getFileID()))) {
90 llvm::dbgs() <<
"File encoding: "
97std::pair<tooling::Replacements, unsigned>
100 llvm::SpecificBumpPtrAllocator<FormatToken> Allocator;
109 Allocator, IdentTable);
112 unsigned Penalty = 0;
113 for (
unsigned Run = 0, RunE =
UnwrappedLines.size(); Run + 1 != RunE; ++Run) {
115 LLVM_DEBUG(llvm::dbgs() <<
"Run " << Run <<
"...\n");
117 AnnotatedLines.reserve(Lines.size());
123 Annotator.
annotate(*AnnotatedLines.back());
126 std::pair<tooling::Replacements, unsigned> RunResult =
127 analyze(Annotator, AnnotatedLines, Lex);
130 llvm::dbgs() <<
"Replacements for run " << Run <<
":\n";
132 llvm::dbgs() << Fix.
toString() <<
"\n";
137 Penalty += RunResult.second;
138 for (
const auto &R : RunResult.first) {
143 llvm::errs() << llvm::toString(std::move(Err)) <<
"\n";
AffectedRangeManager class manages affected ranges in the code.
Defines the Diagnostic-related interfaces.
Contains functions for text encoding manipulation.
Defines the SourceManager interface.
This file declares an abstract TokenAnalyzer, and associated helper classes.
This file implements a token annotator, i.e.
This file contains the declaration of the UnwrappedLineParser, which turns a stream of tokens into Un...
static CharSourceRange getCharRange(SourceRange R)
Abstract interface, implemented by clients of the front-end, which formats and prints fully processed...
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine a...
void FormatDiagnostic(SmallVectorImpl< char > &OutStr) const
Format this diagnostic into a string, substituting the formal arguments into the %0 slots.
Level
The level of the diagnostic, after it has been through mapping.
Implements an efficient mapping from strings to IdentifierInfo nodes.
Parser - This implements a parser for the C family of languages.
Encodes a location in the source.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
SourceManager and necessary dependencies (e.g.
The JSON file list parser is used to communicate input to InstallAPI.
@ Result
The result type of a method or function.