28#include "llvm/ADT/STLExtras.h"
29#include "llvm/ADT/SmallVector.h"
30#include "llvm/Support/Debug.h"
33#define DEBUG_TYPE "format-formatter"
48 llvm::errs() << Message <<
"\n";
58std::unique_ptr<Environment>
61 unsigned NextStartColumn,
unsigned LastStartColumn) {
62 auto Env = std::make_unique<Environment>(Code,
FileName, FirstStartColumn,
63 NextStartColumn, LastStartColumn);
65 Env->SM.getDiagnostics().setClient(&Diags,
false);
73 Env->SM.getBufferData(
Env->ID);
80 unsigned FirstStartColumn,
unsigned NextStartColumn,
81 unsigned LastStartColumn)
83 ID(VirtualSM->get().getMainFileID()), FirstStartColumn(FirstStartColumn),
84 NextStartColumn(NextStartColumn), LastStartColumn(LastStartColumn) {}
88 AffectedRangeMgr(
Env.getSourceManager(),
Env.getCharRanges()),
90 Encoding(encoding::detectEncoding(
91 Env.getSourceManager().getBufferData(
Env.getFileID()))) {
93 llvm::dbgs() <<
"File encoding: "
100std::pair<tooling::Replacements, unsigned>
103 llvm::SpecificBumpPtrAllocator<FormatToken> Allocator;
112 Allocator, IdentTable);
115 unsigned Penalty = 0;
116 for (
unsigned Run = 0, RunE =
UnwrappedLines.size(); Run + 1 != RunE; ++Run) {
118 LLVM_DEBUG(llvm::dbgs() <<
"Run " << Run <<
"...\n");
120 AnnotatedLines.reserve(Lines.size());
126 Annotator.
annotate(*AnnotatedLines.back());
129 std::pair<tooling::Replacements, unsigned> RunResult =
130 analyze(Annotator, AnnotatedLines, Lex);
133 llvm::dbgs() <<
"Replacements for run " << Run <<
":\n";
135 llvm::dbgs() << Fix.
toString() <<
"\n";
140 Penalty += RunResult.second;
141 for (
const auto &R : RunResult.first) {
146 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 clang::FileManager interface and associated types.
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.