clang-tools 17.0.0git
|
Stores and provides access to parsed AST. More...
#include <ParsedAST.h>
Public Member Functions | |
ParsedAST (ParsedAST &&Other) | |
ParsedAST & | operator= (ParsedAST &&Other) |
~ParsedAST () | |
ASTContext & | getASTContext () |
Note that the returned ast will not contain decls from the preamble that were not deserialized during parsing. | |
const ASTContext & | getASTContext () const |
Sema & | getSema () |
Preprocessor & | getPreprocessor () |
std::shared_ptr< Preprocessor > | getPreprocessorPtr () |
const Preprocessor & | getPreprocessor () const |
SourceManager & | getSourceManager () |
const SourceManager & | getSourceManager () const |
const LangOptions & | getLangOpts () const |
ArrayRef< Decl * > | getLocalTopLevelDecls () |
This function returns top-level decls present in the main file of the AST. | |
ArrayRef< const Decl * > | getLocalTopLevelDecls () const |
const std::optional< std::vector< Diag > > & | getDiagnostics () const |
std::size_t | getUsedBytes () const |
Returns the estimated size of the AST and the accessory structures, in bytes. | |
const IncludeStructure & | getIncludeStructure () const |
const CanonicalIncludes & | getCanonicalIncludes () const |
const MainFileMacros & | getMacros () const |
Gets all macro references (definition, expansions) present in the main file, including those in the preamble region. | |
const std::vector< PragmaMark > & | getMarks () const |
Gets all pragma marks in the main file. | |
const syntax::TokenBuffer & | getTokens () const |
Tokens recorded while parsing the main file. | |
const include_cleaner::PragmaIncludes * | getPragmaIncludes () const |
Returns the PramaIncludes from the preamble. | |
llvm::StringRef | version () const |
Returns the version of the ParseInputs this AST was built from. | |
PathRef | tuPath () const |
Returns the path passed by the caller when building this AST. | |
std::optional< llvm::StringRef > | preambleVersion () const |
Returns the version of the ParseInputs used to build Preamble part of this AST. | |
const HeuristicResolver * | getHeuristicResolver () const |
Static Public Member Functions | |
static std::optional< ParsedAST > | build (llvm::StringRef Filename, const ParseInputs &Inputs, std::unique_ptr< clang::CompilerInvocation > CI, llvm::ArrayRef< Diag > CompilerInvocationDiags, std::shared_ptr< const PreambleData > Preamble) |
Attempts to run Clang and store the parsed AST. | |
Stores and provides access to parsed AST.
Definition at line 47 of file ParsedAST.h.
|
default |
clang::clangd::ParsedAST::~ParsedAST | ( | ) |
Definition at line 700 of file ParsedAST.cpp.
|
static |
Attempts to run Clang and store the parsed AST.
If Preamble
is non-null it is reused during parsing. This function does not check if preamble is valid to reuse.
Definition at line 345 of file ParsedAST.cpp.
References clang::tidy::ClangTidyOptions::Checks, CI, Clang, clang::tidy::configurationAsText(), clang::clangd::StoreDiags::contributeFixes(), clang::tidy::ClangTidyCheckFactories::createChecksForLanguage(), clang::clangd::PreamblePatch::createFullPatch(), clang::clangd::Config::current(), Directive, dlog, E, clang::clangd::elog(), clang::tidy::ClangTidyOptions::ExtraArgs, clang::tidy::ClangTidyOptions::ExtraArgsBefore, Filename, clang::clangd::getFormatStyleForFile(), clang::clangd::getTidyOptionsForFile(), clang::clangd::Symbol::Include, clang::clangd::Info, clang::clangd::isBuiltinDiagnosticSuppressed(), clang::clangd::log(), M, clang::clangd::DiagBase::Message, Patch, Preamble, clang::clangd::preferredIncludeDirective(), clang::clangd::prepareCompilerInstance(), clang::clangd::StoreDiags::setDiagCallback(), clang::clangd::StoreDiags::setLevelAdjuster(), SPAN_ATTACH, and clang::clangd::StoreDiags::take().
Referenced by clang::clangd::TestTU::build().
ASTContext & clang::clangd::ParsedAST::getASTContext | ( | ) |
Note that the returned ast will not contain decls from the preamble that were not deserialized during parsing.
Clients should expect only decls from the main file to be in the AST.
Definition at line 711 of file ParsedAST.cpp.
References Clang.
Referenced by getLangOpts(), and getSourceManager().
const ASTContext & clang::clangd::ParsedAST::getASTContext | ( | ) | const |
Definition at line 713 of file ParsedAST.cpp.
References Clang.
const CanonicalIncludes & clang::clangd::ParsedAST::getCanonicalIncludes | ( | ) | const |
Definition at line 776 of file ParsedAST.cpp.
|
inline |
Definition at line 92 of file ParsedAST.h.
|
inline |
Definition at line 124 of file ParsedAST.h.
const IncludeStructure & clang::clangd::ParsedAST::getIncludeStructure | ( | ) | const |
Definition at line 772 of file ParsedAST.cpp.
|
inline |
Definition at line 82 of file ParsedAST.h.
References getASTContext().
llvm::ArrayRef< Decl * > clang::clangd::ParsedAST::getLocalTopLevelDecls | ( | ) |
This function returns top-level decls present in the main file of the AST.
The result does not include the decls that come from the preamble. (These should be const, but RecursiveASTVisitor requires Decl*).
Definition at line 729 of file ParsedAST.cpp.
llvm::ArrayRef< const Decl * > clang::clangd::ParsedAST::getLocalTopLevelDecls | ( | ) | const |
Definition at line 733 of file ParsedAST.cpp.
const MainFileMacros & clang::clangd::ParsedAST::getMacros | ( | ) | const |
Gets all macro references (definition, expansions) present in the main file, including those in the preamble region.
Definition at line 737 of file ParsedAST.cpp.
const std::vector< PragmaMark > & clang::clangd::ParsedAST::getMarks | ( | ) | const |
Gets all pragma marks in the main file.
Definition at line 738 of file ParsedAST.cpp.
const include_cleaner::PragmaIncludes * clang::clangd::ParsedAST::getPragmaIncludes | ( | ) | const |
Returns the PramaIncludes from the preamble.
Might be null if AST is built without a preamble.
Definition at line 800 of file ParsedAST.cpp.
References Preamble.
Preprocessor & clang::clangd::ParsedAST::getPreprocessor | ( | ) |
Definition at line 719 of file ParsedAST.cpp.
References Clang.
const Preprocessor & clang::clangd::ParsedAST::getPreprocessor | ( | ) | const |
Definition at line 725 of file ParsedAST.cpp.
References Clang.
std::shared_ptr< Preprocessor > clang::clangd::ParsedAST::getPreprocessorPtr | ( | ) |
Definition at line 721 of file ParsedAST.cpp.
References Clang.
Sema & clang::clangd::ParsedAST::getSema | ( | ) |
Definition at line 717 of file ParsedAST.cpp.
References Clang.
|
inline |
Definition at line 75 of file ParsedAST.h.
References getASTContext().
Referenced by clang::clangd::Tweak::Selection::Selection().
|
inline |
Definition at line 78 of file ParsedAST.h.
References getASTContext().
|
inline |
Tokens recorded while parsing the main file.
(!) does not have tokens from the preamble.
Definition at line 109 of file ParsedAST.h.
std::size_t clang::clangd::ParsedAST::getUsedBytes | ( | ) | const |
Returns the estimated size of the AST and the accessory structures, in bytes.
Does not include the size of the preamble.
Definition at line 740 of file ParsedAST.cpp.
References Total.
std::optional< llvm::StringRef > clang::clangd::ParsedAST::preambleVersion | ( | ) | const |
Returns the version of the ParseInputs used to build Preamble part of this AST.
Might be std::nullopt if no Preamble is used.
Definition at line 806 of file ParsedAST.cpp.
References Preamble.
|
inline |
Returns the path passed by the caller when building this AST.
Definition at line 118 of file ParsedAST.h.
|
inline |
Returns the version of the ParseInputs this AST was built from.
Definition at line 115 of file ParsedAST.h.