clang-tools 20.0.0git
|
Stores information required to parse a TU using a (possibly stale) Baseline preamble. More...
#include <Preamble.h>
Public Types | |
enum class | PatchType { MacroDirectives , All } |
Public Member Functions | |
void | apply (CompilerInvocation &CI) const |
Adjusts CI (which compiles the modified inputs) to be used with the baseline preamble. | |
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. | |
llvm::StringRef | text () const |
Returns textual patch contents. | |
llvm::ArrayRef< Diag > | patchedDiags () const |
Returns diag locations for Modified contents. | |
llvm::ArrayRef< PragmaMark > | marks () const |
const MainFileMacros & | mainFileMacros () const |
Static Public Member Functions | |
static PreamblePatch | unmodified (const PreambleData &Preamble) |
Preamble is used verbatim. | |
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 compared to Baseline . | |
static PreamblePatch | createMacroPatch (llvm::StringRef FileName, const ParseInputs &Modified, const PreambleData &Baseline) |
static OptionalFileEntryRef | getPatchEntry (llvm::StringRef MainFilePath, const SourceManager &SM) |
Returns the FileEntry for the preamble patch of MainFilePath in SM, if any. | |
Static Public Attributes | |
static constexpr llvm::StringLiteral | HeaderName = "__preamble_patch__.h" |
Stores information required to parse a TU using a (possibly stale) Baseline preamble.
Later on this information can be injected into the main file by updating compiler invocation with apply
. This injected section approximately reflects additions to the preamble in Modified contents, e.g. new include directives.
Definition at line 175 of file Preamble.h.
|
strong |
Enumerator | |
---|---|
MacroDirectives | |
All |
Definition at line 177 of file Preamble.h.
void clang::clangd::PreamblePatch::apply | ( | CompilerInvocation & | CI | ) | const |
Adjusts CI (which compiles the modified inputs) to be used with the baseline preamble.
This is done by inserting an artificial include to the CI
that contains new directives calculated in create.
Definition at line 932 of file Preamble.cpp.
References CI.
|
static |
Builds a patch that contains new PP directives introduced to the preamble section of Modified
compared to Baseline
.
FIXME: This only handles include directives, we should at least handle define/undef.
Definition at line 920 of file Preamble.cpp.
Referenced by clang::clangd::ParsedAST::build().
|
static |
Definition at line 926 of file Preamble.cpp.
References FileName, and MacroDirectives.
|
static |
Returns the FileEntry for the preamble patch of MainFilePath in SM, if any.
Definition at line 981 of file Preamble.cpp.
References clang::clangd::getPatchName().
Referenced by clang::clangd::computeIncludeCleanerFindings().
const MainFileMacros & clang::clangd::PreamblePatch::mainFileMacros | ( | ) | const |
Definition at line 975 of file Preamble.cpp.
llvm::ArrayRef< PragmaMark > clang::clangd::PreamblePatch::marks | ( | ) | const |
Definition at line 969 of file Preamble.cpp.
|
inline |
Returns preamble bounds for the Modified.
Definition at line 209 of file Preamble.h.
|
inline |
Returns diag locations for Modified contents.
Definition at line 215 of file Preamble.h.
std::vector< Inclusion > clang::clangd::PreamblePatch::preambleIncludes | ( | ) | const |
Returns #include directives from the Modified
preamble that were resolved using the Baseline
preamble.
This covers the new locations of inclusions that were moved around, but not inclusions of new files. Those will be recorded when parsing the main file: the includes in the injected section will be resolved back to their spelled positions in the main file using the presumed-location mechanism.
Definition at line 956 of file Preamble.cpp.
|
inline |
Returns textual patch contents.
Definition at line 212 of file Preamble.h.
|
static |
Preamble
is used verbatim.
Definition at line 960 of file Preamble.cpp.
References clang::clangd::Preamble.
|
staticconstexpr |
Definition at line 217 of file Preamble.h.
Referenced by clang::clangd::getPatchName().