clang-tools  16.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. More...
 
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. More...
 
const llvm::Optional< std::vector< Diag > > & getDiagnostics () const
 
std::size_t getUsedBytes () const
 Returns the estimated 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 std::vector< PragmaMark > & getMarks () const
 Gets all pragma marks in the main file. More...
 
const syntax::TokenBuffer & getTokens () const
 Tokens recorded while parsing the main file. More...
 
llvm::StringRef version () const
 Returns the version of the ParseInputs this AST was built from. More...
 
PathRef tuPath () const
 Returns the path passed by the caller when building this AST. More...
 
llvm::Optional< llvm::StringRef > preambleVersion () const
 Returns the version of the ParseInputs used to build Preamble part of this AST. More...
 
const HeuristicResolvergetHeuristicResolver () const
 

Static Public Member Functions

static llvm::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. 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

◆ ~ParsedAST()

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

Definition at line 689 of file ParsedAST.cpp.

References Action.

Member Function Documentation

◆ build()

llvm::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

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

References CI, ns1::ns2::D, Diagnostic, Filename, Inputs, M, Preamble, clang::clangd::StoreDiags::setDiagCallback(), SPAN_ATTACH, and Tracer.

◆ getASTContext() [1/2]

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

References Clang.

Referenced by clang::clangd::findDecl(), clang::clangd::findReferencedLocations(), clang::clangd::getFoldingRanges(), getLangOpts(), clang::clangd::getSemanticHighlightings(), getSourceManager(), and clang::clangd::indexMainDecls().

◆ getASTContext() [2/2]

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

◆ getCanonicalIncludes()

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

Definition at line 761 of file ParsedAST.cpp.

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

◆ getDiagnostics()

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

Definition at line 90 of file ParsedAST.h.

◆ getHeuristicResolver()

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

Definition at line 119 of file ParsedAST.h.

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

◆ getIncludeStructure()

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

Definition at line 757 of file ParsedAST.cpp.

◆ getLangOpts()

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

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

Referenced by clang::clangd::getIndexableLocalDecls(), 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 722 of file ParsedAST.cpp.

References Macros.

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

◆ getMarks()

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

Gets all pragma marks in the main file.

Definition at line 723 of file ParsedAST.cpp.

◆ getPreprocessor() [1/2]

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

Definition at line 708 of file ParsedAST.cpp.

References Clang.

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

◆ getPreprocessor() [2/2]

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

◆ getPreprocessorPtr()

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

Definition at line 710 of file ParsedAST.cpp.

References Clang.

◆ getSema()

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

Definition at line 706 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::getFoldingRanges().

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

Referenced by clang::clangd::findReferencedLocations(), and clang::clangd::getFoldingRanges().

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

References Diags, and Total.

◆ operator=()

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

◆ preambleVersion()

llvm::Optional< llvm::StringRef > clang::clangd::ParsedAST::preambleVersion ( ) const

Returns the version of the ParseInputs used to build Preamble part of this AST.

Might be None if no Preamble is used.

Definition at line 785 of file ParsedAST.cpp.

References Preamble.

◆ 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.

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


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