29 #include "llvm/ADT/STLExtras.h" 30 #include "llvm/Support/Debug.h" 32 #define DEBUG_TYPE "format-formatter" 39 std::unique_ptr<Environment>
42 unsigned FirstStartColumn,
43 unsigned NextStartColumn,
44 unsigned LastStartColumn) {
51 std::unique_ptr<FileManager> FileMgr(
60 std::unique_ptr<SourceManager> VirtualSM(
62 InMemoryFileSystem->addFile(
64 llvm::MemoryBuffer::getMemBuffer(Code, FileName,
66 FileID ID = VirtualSM->createFileID(FileMgr->getFile(FileName),
70 std::vector<CharSourceRange> CharRanges;
76 return llvm::make_unique<Environment>(
77 ID, std::move(FileMgr), std::move(VirtualSM), std::move(Diagnostics),
78 CharRanges, FirstStartColumn, NextStartColumn, LastStartColumn);
82 : Style(Style), Env(Env),
88 llvm::dbgs() <<
"File encoding: " 104 unsigned Penalty = 0;
105 for (
unsigned Run = 0, RunE =
UnwrappedLines.size(); Run + 1 != RunE; ++Run) {
106 DEBUG(llvm::dbgs() <<
"Run " << Run <<
"...\n");
110 for (
unsigned i = 0, e =
UnwrappedLines[Run].size(); i != e; ++i) {
112 Annotator.annotate(*AnnotatedLines.back());
115 std::pair<tooling::Replacements, unsigned> RunResult =
116 analyze(Annotator, AnnotatedLines, Tokens);
119 llvm::dbgs() <<
"Replacements for run " << Run <<
":\n";
121 E = RunResult.first.end();
123 llvm::dbgs() << I->toString() <<
"\n";
126 for (
unsigned i = 0, e = AnnotatedLines.size(); i != e; ++i) {
127 delete AnnotatedLines[i];
130 Penalty += RunResult.second;
131 for (
const auto &R : RunResult.first) {
132 auto Err = Result.
add(R);
141 return {Result, Penalty};
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
Implements support for file system lookup, file system caching, and directory search management...
Defines the clang::FileManager interface and associated types.
Defines the SourceManager interface.
AffectedRangeManager class manages affected ranges in the code.
Parser - This implements a parser for the C family of languages.
Contains functions for text encoding manipulation.
This file implements a token annotator, i.e.
An in-memory file system.
Concrete class used by the front-end to report problems and issues.
Defines the Diagnostic-related interfaces.
static CharSourceRange getCharRange(SourceRange R)
Encodes a location in the source.
Options for controlling the compiler diagnostics engine.
This file contains the declaration of the UnwrappedLineParser, which turns a stream of tokens into Un...
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Dataflow Directional Tag Classes.
Used for handling and querying diagnostic IDs.
std::string toString(const til::SExpr *E)
Keeps track of options that affect how file operations are performed.
This file declares an abstract TokenAnalyzer, and associated helper classes.
This class handles loading and caching of source files into memory.