Go to the documentation of this file.
20 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_PARSEDAST_H
21 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_PARSEDAST_H
30 #include "clang/Frontend/FrontendAction.h"
31 #include "clang/Frontend/PrecompiledPreamble.h"
32 #include "clang/Lex/Preprocessor.h"
33 #include "clang/Tooling/CompilationDatabase.h"
34 #include "clang/Tooling/Syntax/Tokens.h"
35 #include "llvm/ADT/ArrayRef.h"
36 #include "llvm/ADT/None.h"
37 #include "llvm/ADT/Optional.h"
38 #include "llvm/ADT/StringRef.h"
53 static llvm::Optional<ParsedAST>
55 std::unique_ptr<clang::CompilerInvocation>
CI,
56 llvm::ArrayRef<Diag> CompilerInvocationDiags,
57 std::shared_ptr<const PreambleData> Preamble);
103 const syntax::TokenBuffer &
getTokens()
const {
return Tokens; }
106 llvm::StringRef
version()
const {
return Version; }
114 std::shared_ptr<const PreambleData> Preamble,
115 std::unique_ptr<CompilerInstance> Clang,
116 std::unique_ptr<FrontendAction> Action, syntax::TokenBuffer Tokens,
124 std::shared_ptr<const PreambleData>
Preamble;
130 std::unique_ptr<CompilerInstance> Clang;
131 std::unique_ptr<FrontendAction> Action;
136 syntax::TokenBuffer Tokens;
141 std::vector<Diag> Diags;
144 std::vector<Decl *> LocalTopLevelDecls;
151 void dumpAST(ParsedAST &AST, llvm::raw_ostream &
OS);
156 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_PARSEDAST_H
ASTContext & getASTContext()
Note that the returned ast will not contain decls from the preamble that were not deserialized during...
std::shared_ptr< Preprocessor > getPreprocessorPtr()
const IncludeStructure & getIncludeStructure() const
std::unique_ptr< CompilerInvocation > CI
std::string Filename
Filename as a string.
const CanonicalIncludes & getCanonicalIncludes() const
const LangOptions & getLangOpts() const
const PreambleData & Preamble
ParsedAST(ParsedAST &&Other)
static llvm::Optional< ParsedAST > build(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.
llvm::StringRef version() const
Returns the version of the ParseInputs this AST was built from.
Maps a definition location onto an #include file, based on a set of filename rules.
ParsedAST & operator=(ParsedAST &&Other)
Preprocessor & getPreprocessor()
const std::vector< Diag > & getDiagnostics() const
void dumpAST(ParsedAST &AST, llvm::raw_ostream &OS)
For testing/debugging purposes.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
llvm::raw_string_ostream OS
const syntax::TokenBuffer & getTokens() const
Tokens recorded while parsing the main file.
ArrayRef< Decl * > getLocalTopLevelDecls()
This function returns top-level decls present in the main file of the AST.
std::size_t getUsedBytes() const
Returns the estimated size of the AST and the accessory structures, in bytes.
Stores and provides access to parsed AST.
SourceManager & getSourceManager()
const SourceManager & getSourceManager() const
llvm::Optional< llvm::StringRef > preambleVersion() const
Returns the version of the ParseInputs used to build Preamble part of this AST.
const MainFileMacros & getMacros() const
Gets all macro references (definition, expansions) present in the main file, including those in the p...