21 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_PARSEDAST_H 22 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_PARSEDAST_H 31 #include "clang/Frontend/FrontendAction.h" 32 #include "clang/Frontend/PrecompiledPreamble.h" 33 #include "clang/Lex/Preprocessor.h" 34 #include "clang/Tooling/CompilationDatabase.h" 35 #include "clang/Tooling/Syntax/Tokens.h" 36 #include "llvm/ADT/ArrayRef.h" 50 static llvm::Optional<ParsedAST>
51 build(std::unique_ptr<clang::CompilerInvocation> CI,
52 llvm::ArrayRef<Diag> CompilerInvocationDiags,
53 std::shared_ptr<const PreambleData> Preamble,
54 std::unique_ptr<llvm::MemoryBuffer> Buffer,
55 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>
VFS,
102 const syntax::TokenBuffer &
getTokens()
const {
return Tokens; }
105 ParsedAST(std::shared_ptr<const PreambleData> Preamble,
106 std::unique_ptr<CompilerInstance> Clang,
107 std::unique_ptr<FrontendAction> Action, syntax::TokenBuffer Tokens,
114 std::shared_ptr<const PreambleData> Preamble;
120 std::unique_ptr<CompilerInstance> Clang;
121 std::unique_ptr<FrontendAction> Action;
126 syntax::TokenBuffer Tokens;
131 std::vector<Diag> Diags;
134 std::vector<Decl *> LocalTopLevelDecls;
142 llvm::Optional<ParsedAST>
144 llvm::ArrayRef<Diag> CompilerInvocationDiags,
146 std::shared_ptr<const PreambleData> Preamble);
155 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_PARSEDAST_H
ParsedAST & operator=(ParsedAST &&Other)
const LangOptions & getLangOpts() const
llvm::Optional< ParsedAST > buildAST(PathRef FileName, std::unique_ptr< CompilerInvocation > Invocation, llvm::ArrayRef< Diag > CompilerInvocationDiags, const ParseInputs &Inputs, std::shared_ptr< const PreambleData > Preamble)
Build an AST from provided user inputs.
Preprocessor & getPreprocessor()
llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > VFS
void dumpAST(ParsedAST &AST, llvm::raw_ostream &OS)
For testing/debugging purposes.
Interface for symbol indexes that can be used for searching or matching symbols among a set of symbol...
llvm::StringRef PathRef
A typedef to represent a ref to file path.
ArrayRef< Decl * > getLocalTopLevelDecls()
This function returns top-level decls present in the main file of the AST.
const syntax::TokenBuffer & getTokens() const
Tokens recorded while parsing the main file.
ASTContext & getASTContext()
Note that the returned ast will not contain decls from the preamble that were not deserialized during...
std::size_t getUsedBytes() const
Returns the estimated size of the AST and the accessory structures, in bytes.
Maps a definition location onto an #include file, based on a set of filename rules.
const CanonicalIncludes & getCanonicalIncludes() const
const IncludeStructure & getIncludeStructure() const
const SourceManager & getSourceManager() const
std::shared_ptr< Preprocessor > getPreprocessorPtr()
Stores and provides access to parsed AST.
SourceManager & getSourceManager()
const MainFileMacros & getMacros() const
Gets all macro references (definition, expansions) present in the main file, including those in the p...
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
static llvm::Optional< 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)
Attempts to run Clang and store parsed AST.
ParsedAST(ParsedAST &&Other)
const std::vector< Diag > & getDiagnostics() const
const SymbolIndex * Index