clang-tools  9.0.0
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 <ClangdUnit.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. More...
 
const ASTContext & getASTContext () const
 
Preprocessor & getPreprocessor ()
 
std::shared_ptr< Preprocessor > getPreprocessorPtr ()
 
const Preprocessor & getPreprocessor () const
 
SourceManager & getSourceManager ()
 
const SourceManager & getSourceManager () const
 
ArrayRef< Decl * > getLocalTopLevelDecls ()
 This function returns top-level decls present in the main file of the AST. More...
 
const std::vector< Diag > & getDiagnostics () const
 
std::size_t getUsedBytes () const
 Returns the esitmated size of the AST and the accessory structures, in bytes. More...
 
const IncludeStructuregetIncludeStructure () const
 
const CanonicalIncludesgetCanonicalIncludes () const
 
const syntax::TokenBuffer & getTokens () const
 Tokens recorded while parsing the main file. More...
 

Static Public Member Functions

static llvm::Optional< ParsedASTbuild (std::unique_ptr< clang::CompilerInvocation > CI, std::shared_ptr< const PreambleData > Preamble, std::unique_ptr< llvm::MemoryBuffer > Buffer, IntrusiveRefCntPtr< llvm::vfs::FileSystem > VFS, const SymbolIndex *Index, const ParseOptions &Opts)
 Attempts to run Clang and store parsed AST. More...
 

Detailed Description

Stores and provides access to parsed AST.

Definition at line 73 of file ClangdUnit.h.

Constructor & Destructor Documentation

◆ ParsedAST()

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

◆ ~ParsedAST()

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

Definition at line 466 of file ClangdUnit.cpp.

References Action.

Member Function Documentation

◆ build()

llvm::Optional< ParsedAST > clang::clangd::ParsedAST::build ( std::unique_ptr< clang::CompilerInvocation >  CI,
std::shared_ptr< const PreambleData Preamble,
std::unique_ptr< llvm::MemoryBuffer >  Buffer,
IntrusiveRefCntPtr< llvm::vfs::FileSystem >  VFS,
const SymbolIndex Index,
const ParseOptions Opts 
)
static

Attempts to run Clang and store parsed AST.

If Preamble is non-null it is reused during parsing.

Definition at line 287 of file ClangdUnit.cpp.

◆ 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 477 of file ClangdUnit.cpp.

Referenced by clang::clangd::findDecl(), clang::clangd::getBeginningOfIdentifier(), clang::clangd::getTypeHierarchy(), and clang::clangd::indexMainDecls().

◆ getASTContext() [2/2]

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

Definition at line 479 of file ClangdUnit.cpp.

◆ getCanonicalIncludes()

const CanonicalIncludes & clang::clangd::ParsedAST::getCanonicalIncludes ( ) const

Definition at line 535 of file ClangdUnit.cpp.

Referenced by clang::clangd::indexMainDecls().

◆ getDiagnostics()

const std::vector< Diag > & clang::clangd::ParsedAST::getDiagnostics ( ) const

Definition at line 497 of file ClangdUnit.cpp.

◆ getIncludeStructure()

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

Definition at line 531 of file ClangdUnit.cpp.

◆ getLocalTopLevelDecls()

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 493 of file ClangdUnit.cpp.

Referenced by clang::clangd::indexMainDecls().

◆ getPreprocessor() [1/2]

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

Definition at line 483 of file ClangdUnit.cpp.

◆ getPreprocessor() [2/2]

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

Definition at line 489 of file ClangdUnit.cpp.

◆ getPreprocessorPtr()

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

Definition at line 485 of file ClangdUnit.cpp.

Referenced by clang::clangd::indexMainDecls().

◆ getSourceManager() [1/2]

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

Definition at line 99 of file ClangdUnit.h.

Referenced by clang::clangd::findRecordTypeAt().

◆ getSourceManager() [2/2]

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

Definition at line 102 of file ClangdUnit.h.

◆ 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 121 of file ClangdUnit.h.

References Action, and Tokens.

◆ getUsedBytes()

std::size_t clang::clangd::ParsedAST::getUsedBytes ( ) const

Returns the esitmated size of the AST and the accessory structures, in bytes.

Does not include the size of the preamble.

Definition at line 499 of file ClangdUnit.cpp.

References clang::clangd::AST.

◆ operator=()

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

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