22#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_PREAMBLE_H
23#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_PREAMBLE_H
30#include "clang-include-cleaner/Record.h"
33#include "clang/Basic/SourceManager.h"
34#include "clang/Frontend/CompilerInvocation.h"
35#include "clang/Frontend/PrecompiledPreamble.h"
36#include "clang/Lex/Lexer.h"
37#include "clang/Tooling/CompilationDatabase.h"
38#include "llvm/ADT/ArrayRef.h"
39#include "llvm/ADT/StringRef.h"
108std::shared_ptr<const PreambleData>
120 const CompilerInvocation &
CI);
144 static const FileEntry *
getPatchEntry(llvm::StringRef MainFilePath,
145 const SourceManager &SM);
150 void apply(CompilerInvocation &
CI)
const;
164 llvm::StringRef
text()
const {
return PatchContents; }
172 static constexpr llvm::StringLiteral
HeaderName =
"__preamble_patch__.h";
174 llvm::ArrayRef<PragmaMark>
marks()
const;
184 std::string PatchContents;
185 std::string PatchFileName;
188 std::vector<Inclusion> PreambleIncludes;
190 std::vector<Diag> PatchedDiags;
191 PreambleBounds ModifiedBounds = {0,
false};
193 std::vector<PragmaMark> PatchedMarks;
std::unique_ptr< CompilerInvocation > CI
Maps a definition location onto an #include file, based on a set of filename rules.
Stores information required to parse a TU using a (possibly stale) Baseline preamble.
bool preserveDiagnostics() const
Whether diagnostics generated using this patch are trustable.
const MainFileMacros & mainFileMacros() const
llvm::ArrayRef< PragmaMark > marks() const
void apply(CompilerInvocation &CI) const
Adjusts CI (which compiles the modified inputs) to be used with the baseline preamble.
static PreamblePatch unmodified(const PreambleData &Preamble)
Preamble is used verbatim.
llvm::ArrayRef< Diag > patchedDiags() const
Returns diag locations for Modified contents.
llvm::StringRef text() const
Returns textual patch contents.
static PreamblePatch createMacroPatch(llvm::StringRef FileName, const ParseInputs &Modified, const PreambleData &Baseline)
static const FileEntry * getPatchEntry(llvm::StringRef MainFilePath, const SourceManager &SM)
Returns the FileEntry for the preamble patch of MainFilePath in SM, if any.
static PreamblePatch createFullPatch(llvm::StringRef FileName, const ParseInputs &Modified, const PreambleData &Baseline)
Builds a patch that contains new PP directives introduced to the preamble section of Modified compare...
static constexpr llvm::StringLiteral HeaderName
std::vector< Inclusion > preambleIncludes() const
Returns #include directives from the Modified preamble that were resolved using the Baseline preamble...
PreambleBounds modifiedBounds() const
Returns preamble bounds for the Modified.
bool isPreambleCompatible(const PreambleData &Preamble, const ParseInputs &Inputs, PathRef FileName, const CompilerInvocation &CI)
Returns true if Preamble is reusable for Inputs.
std::shared_ptr< const PreambleData > buildPreamble(PathRef FileName, CompilerInvocation CI, const ParseInputs &Inputs, bool StoreInMemory, PreambleParsedCallback PreambleCallback, PreambleBuildStats *Stats)
Build a preamble for the new inputs unless an old one can be reused.
std::function< void(ASTContext &, Preprocessor &, const CanonicalIncludes &)> PreambleParsedCallback
llvm::StringRef PathRef
A typedef to represent a ref to file path.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Timings and statistics from the premble build.
double FileSystemTime
Time spent in filesystem operations during the build, in seconds.
size_t BuildSize
Estimate of the memory used while building the preamble.
double TotalBuildTime
Total wall time it took to build preamble, in seconds.
size_t SerializedSize
The serialized size of the preamble.
The parsed preamble and associated data.
std::vector< Diag > Diags
std::vector< PragmaMark > Marks
PrecompiledPreamble Preamble
CanonicalIncludes CanonIncludes
std::unique_ptr< PreambleFileStatusCache > StatCache
PreambleData(PrecompiledPreamble Preamble)
include_cleaner::PragmaIncludes Pragmas
bool MainIsIncludeGuarded
tooling::CompileCommand CompileCommand
IncludeStructure Includes