29 #include "llvm/ADT/STLExtras.h"
30 #include "llvm/Support/Debug.h"
32 #define DEBUG_TYPE "format-formatter"
39 std::unique_ptr<Environment>
48 std::unique_ptr<FileManager> FileMgr(
57 std::unique_ptr<SourceManager> VirtualSM(
59 InMemoryFileSystem->addFile(
60 FileName, 0, llvm::MemoryBuffer::getMemBuffer(
61 Code, FileName,
false));
62 FileID ID = VirtualSM->createFileID(FileMgr->getFile(FileName),
66 std::vector<CharSourceRange> CharRanges;
72 return llvm::make_unique<Environment>(ID, std::move(FileMgr),
74 std::move(Diagnostics), CharRanges);
78 : Style(Style), Env(Env),
79 AffectedRangeMgr(Env.getSourceManager(), Env.getCharRanges()),
82 Env.getSourceManager().getBufferData(Env.getFileID()))) {
84 llvm::dbgs() <<
"File encoding: "
99 for (
unsigned Run = 0, RunE =
UnwrappedLines.size(); Run + 1 != RunE; ++Run) {
100 DEBUG(llvm::dbgs() <<
"Run " << Run <<
"...\n");
104 for (
unsigned i = 0, e =
UnwrappedLines[Run].size(); i != e; ++i) {
106 Annotator.annotate(*AnnotatedLines.back());
113 llvm::dbgs() <<
"Replacements for run " << Run <<
":\n";
117 llvm::dbgs() <<
I->toString() <<
"\n";
120 for (
unsigned i = 0, e = AnnotatedLines.size(); i != e; ++i) {
121 delete AnnotatedLines[i];
123 Result.insert(RunResult.begin(), RunResult.end());
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.
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
Concrete class used by the front-end to report problems and issues.
detail::InMemoryDirectory::const_iterator I
The result type of a method or function.
static CharSourceRange getCharRange(SourceRange R)
Encodes a location in the source.
const TemplateArgument * iterator
Options for controlling the compiler diagnostics engine.
ArrayRef< FormatToken * > Tokens
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...
Used for handling and querying diagnostic IDs.
detail::InMemoryDirectory::const_iterator E
Defines the Diagnostic-related interfaces.
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.