clang-tools  10.0.0svn
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. 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 MainFileMacrosgetMacros () const
 Gets all macro references (definition, expansions) present in the main file, including those in the preamble region. More...
 
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, llvm::ArrayRef< Diag > CompilerInvocationDiags, std::shared_ptr< const PreambleData > Preamble, std::unique_ptr< llvm::MemoryBuffer > Buffer, llvm::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 46 of file ParsedAST.h.

Constructor & Destructor Documentation

◆ ParsedAST()

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

Referenced by getTokens().

◆ ~ParsedAST()

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

Definition at line 413 of file ParsedAST.cpp.

References Action.

Member Function Documentation

◆ build()

llvm::Optional< ParsedAST > clang::clangd::ParsedAST::build ( std::unique_ptr< clang::CompilerInvocation >  CI,
llvm::ArrayRef< Diag CompilerInvocationDiags,
std::shared_ptr< const PreambleData Preamble,
std::unique_ptr< llvm::MemoryBuffer >  Buffer,
llvm::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 218 of file ParsedAST.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 424 of file ParsedAST.cpp.

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

◆ getASTContext() [2/2]

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

Definition at line 426 of file ParsedAST.cpp.

◆ getCanonicalIncludes()

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

Definition at line 484 of file ParsedAST.cpp.

Referenced by getSourceManager(), and clang::clangd::indexMainDecls().

◆ getDiagnostics()

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

Definition at line 446 of file ParsedAST.cpp.

Referenced by getSourceManager().

◆ getIncludeStructure()

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

Definition at line 480 of file ParsedAST.cpp.

Referenced by getSourceManager().

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

Referenced by clang::clangd::getIndexableLocalDecls(), getSourceManager(), and clang::clangd::indexMainDecls().

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

Referenced by getSourceManager().

◆ getPreprocessor() [1/2]

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

Definition at line 430 of file ParsedAST.cpp.

◆ getPreprocessor() [2/2]

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

Definition at line 436 of file ParsedAST.cpp.

◆ getPreprocessorPtr()

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

Definition at line 432 of file ParsedAST.cpp.

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

◆ getSourceManager() [1/2]

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

Definition at line 73 of file ParsedAST.h.

References getASTContext().

◆ getSourceManager() [2/2]

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

◆ 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 98 of file ParsedAST.h.

References clang::clangd::AST, clang::clangd::buildAST(), clang::clangd::dumpAST(), FileName, and ParsedAST().

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

References clang::clangd::AST.

Referenced by getSourceManager().

◆ operator=()

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

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