clang-tools 20.0.0git
Public Member Functions | Static Public Member Functions | List of all members
clang::clangd::ParsedAST Class Reference

Stores and provides access to parsed AST. More...

#include <ParsedAST.h>

Public Member Functions

 ParsedAST (ParsedAST &&Other)
 
ParsedASToperator= (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
 
llvm::ArrayRef< DiaggetDiagnostics () const
 
std::size_t getUsedBytes () const
 Returns the estimated size of the AST and the accessory structures, in bytes.
 
const IncludeStructuregetIncludeStructure () const
 
const MainFileMacrosgetMacros () 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 for preamble + main file includes.
 
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 HeuristicResolvergetHeuristicResolver () const
 

Static Public Member Functions

static std::optional< ParsedASTbuild (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.
 

Detailed Description

Stores and provides access to parsed AST.

Definition at line 46 of file ParsedAST.h.

Constructor & Destructor Documentation

◆ ParsedAST()

clang::clangd::ParsedAST::ParsedAST ( ParsedAST &&  Other)
default

◆ ~ParsedAST()

clang::clangd::ParsedAST::~ParsedAST ( )

Definition at line 762 of file ParsedAST.cpp.

References Action, and Clang.

Member Function Documentation

◆ build()

std::optional< ParsedAST > clang::clangd::ParsedAST::build ( llvm::StringRef  Filename,
const ParseInputs Inputs,
std::unique_ptr< clang::CompilerInvocation >  CI,
llvm::ArrayRef< Diag CompilerInvocationDiags,
std::shared_ptr< const PreambleData Preamble 
)
static

◆ getASTContext() [1/2]

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 773 of file ParsedAST.cpp.

References Clang.

Referenced by getLangOpts(), and getSourceManager().

◆ getASTContext() [2/2]

const ASTContext & clang::clangd::ParsedAST::getASTContext ( ) const

Definition at line 775 of file ParsedAST.cpp.

References Clang.

◆ getDiagnostics()

llvm::ArrayRef< Diag > clang::clangd::ParsedAST::getDiagnostics ( ) const

Definition at line 868 of file ParsedAST.cpp.

◆ getHeuristicResolver()

const HeuristicResolver * clang::clangd::ParsedAST::getHeuristicResolver ( ) const
inline

Definition at line 119 of file ParsedAST.h.

◆ getIncludeStructure()

const IncludeStructure & clang::clangd::ParsedAST::getIncludeStructure ( ) const

Definition at line 834 of file ParsedAST.cpp.

◆ getLangOpts()

const LangOptions & clang::clangd::ParsedAST::getLangOpts ( ) const
inline

Definition at line 81 of file ParsedAST.h.

References getASTContext().

◆ getLocalTopLevelDecls() [1/2]

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 791 of file ParsedAST.cpp.

◆ getLocalTopLevelDecls() [2/2]

llvm::ArrayRef< const Decl * > clang::clangd::ParsedAST::getLocalTopLevelDecls ( ) const

Definition at line 795 of file ParsedAST.cpp.

◆ getMacros()

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 799 of file ParsedAST.cpp.

◆ getMarks()

const std::vector< PragmaMark > & clang::clangd::ParsedAST::getMarks ( ) const

Gets all pragma marks in the main file.

Definition at line 800 of file ParsedAST.cpp.

◆ getPragmaIncludes()

const include_cleaner::PragmaIncludes & clang::clangd::ParsedAST::getPragmaIncludes ( ) const

Returns the PramaIncludes for preamble + main file includes.

Definition at line 858 of file ParsedAST.cpp.

◆ getPreprocessor() [1/2]

Preprocessor & clang::clangd::ParsedAST::getPreprocessor ( )

Definition at line 781 of file ParsedAST.cpp.

References Clang.

◆ getPreprocessor() [2/2]

const Preprocessor & clang::clangd::ParsedAST::getPreprocessor ( ) const

Definition at line 787 of file ParsedAST.cpp.

References Clang.

◆ getPreprocessorPtr()

std::shared_ptr< Preprocessor > clang::clangd::ParsedAST::getPreprocessorPtr ( )

Definition at line 783 of file ParsedAST.cpp.

References Clang.

◆ getSema()

Sema & clang::clangd::ParsedAST::getSema ( )

Definition at line 779 of file ParsedAST.cpp.

References Clang.

◆ getSourceManager() [1/2]

SourceManager & clang::clangd::ParsedAST::getSourceManager ( )
inline

Definition at line 74 of file ParsedAST.h.

References getASTContext().

Referenced by clang::clangd::Tweak::Selection::Selection().

◆ getSourceManager() [2/2]

const SourceManager & clang::clangd::ParsedAST::getSourceManager ( ) const
inline

Definition at line 77 of file ParsedAST.h.

References getASTContext().

◆ getTokens()

const syntax::TokenBuffer & clang::clangd::ParsedAST::getTokens ( ) const
inline

Tokens recorded while parsing the main file.

(!) does not have tokens from the preamble.

Definition at line 105 of file ParsedAST.h.

◆ getUsedBytes()

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 802 of file ParsedAST.cpp.

References Total.

◆ operator=()

ParsedAST & clang::clangd::ParsedAST::operator= ( ParsedAST &&  Other)
default

◆ preambleVersion()

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 862 of file ParsedAST.cpp.

◆ tuPath()

PathRef clang::clangd::ParsedAST::tuPath ( ) const
inline

Returns the path passed by the caller when building this AST.

Definition at line 113 of file ParsedAST.h.

◆ version()

llvm::StringRef clang::clangd::ParsedAST::version ( ) const
inline

Returns the version of the ParseInputs this AST was built from.

Definition at line 110 of file ParsedAST.h.


The documentation for this class was generated from the following files: