clang-tools  7.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
 
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
 

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, std::shared_ptr< PCHContainerOperations > PCHs, IntrusiveRefCntPtr< vfs::FileSystem > VFS)
 Attempts to run Clang and store parsed AST. More...
 

Detailed Description

Stores and provides access to parsed AST.

Definition at line 66 of file ClangdUnit.h.

Constructor & Destructor Documentation

◆ ParsedAST()

ParsedAST::ParsedAST ( ParsedAST &&  Other)
default

◆ ~ParsedAST()

ParsedAST::~ParsedAST ( )

Definition at line 184 of file ClangdUnit.cpp.

References Action.

Member Function Documentation

◆ build()

llvm::Optional< ParsedAST > ParsedAST::build ( std::unique_ptr< clang::CompilerInvocation >  CI,
std::shared_ptr< const PreambleData Preamble,
std::unique_ptr< llvm::MemoryBuffer >  Buffer,
std::shared_ptr< PCHContainerOperations >  PCHs,
IntrusiveRefCntPtr< vfs::FileSystem >  VFS 
)
static

Attempts to run Clang and store parsed AST.

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

Definition at line 124 of file ClangdUnit.cpp.

References Action, clang::clangd::collectIncludeStructureCallback(), clang::clangd::StoreDiags::EndSourceFile(), clang::clangd::log(), clang::clangd::None, and clang::clangd::prepareCompilerInstance().

◆ getASTContext() [1/2]

ASTContext & 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 190 of file ClangdUnit.cpp.

Referenced by clang::clangd::dumpAST(), clang::clangd::getBeginningOfIdentifier(), and clang::clangd::getDocumentSymbols().

◆ getASTContext() [2/2]

const ASTContext & ParsedAST::getASTContext ( ) const

Definition at line 192 of file ClangdUnit.cpp.

◆ getDiagnostics()

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

Definition at line 210 of file ClangdUnit.cpp.

◆ getIncludeStructure()

const IncludeStructure & ParsedAST::getIncludeStructure ( ) const

Definition at line 244 of file ClangdUnit.cpp.

◆ getLocalTopLevelDecls()

ArrayRef< Decl * > 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 206 of file ClangdUnit.cpp.

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

◆ getPreprocessor() [1/2]

Preprocessor & ParsedAST::getPreprocessor ( )

Definition at line 196 of file ClangdUnit.cpp.

◆ getPreprocessor() [2/2]

const Preprocessor & ParsedAST::getPreprocessor ( ) const

Definition at line 202 of file ClangdUnit.cpp.

◆ getPreprocessorPtr()

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

Definition at line 198 of file ClangdUnit.cpp.

◆ getUsedBytes()

std::size_t 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 212 of file ClangdUnit.cpp.

References clang::clangd::AST.

◆ operator=()

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

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