20#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_PARSEDAST_H
21#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_PARSEDAST_H
28#include "clang-include-cleaner/Record.h"
30#include "clang/Frontend/FrontendAction.h"
31#include "clang/Lex/Preprocessor.h"
32#include "clang/Tooling/Syntax/Tokens.h"
33#include "llvm/ADT/ArrayRef.h"
34#include "llvm/ADT/StringRef.h"
43class HeuristicResolver;
51 static std::optional<ParsedAST>
53 std::unique_ptr<clang::CompilerInvocation>
CI,
54 llvm::ArrayRef<Diag> CompilerInvocationDiags,
55 std::shared_ptr<const PreambleData> Preamble);
102 const std::vector<PragmaMark> &
getMarks()
const;
105 const syntax::TokenBuffer &
getTokens()
const {
return Tokens; }
110 llvm::StringRef
version()
const {
return Version; }
120 return Resolver.get();
125 std::shared_ptr<const PreambleData> Preamble,
126 std::unique_ptr<CompilerInstance> Clang,
127 std::unique_ptr<FrontendAction> Action, syntax::TokenBuffer Tokens,
129 std::vector<Decl *> LocalTopLevelDecls, std::vector<Diag> Diags,
135 std::shared_ptr<const PreambleData>
Preamble;
141 std::unique_ptr<CompilerInstance> Clang;
142 std::unique_ptr<FrontendAction> Action;
147 syntax::TokenBuffer Tokens;
152 std::vector<PragmaMark> Marks;
155 std::vector<Diag> Diags;
158 std::vector<Decl *> LocalTopLevelDecls;
160 include_cleaner::PragmaIncludes PI;
161 std::unique_ptr<HeuristicResolver> Resolver;
const PreambleData & Preamble
std::string Filename
Filename as a string.
std::unique_ptr< CompilerInvocation > CI
Stores and provides access to parsed AST.
std::size_t getUsedBytes() const
Returns the estimated size of the AST and the accessory structures, in bytes.
PathRef tuPath() const
Returns the path passed by the caller when building this AST.
std::optional< llvm::StringRef > preambleVersion() const
Returns the version of the ParseInputs used to build Preamble part of this AST.
llvm::StringRef version() const
Returns the version of the ParseInputs this AST was built from.
const include_cleaner::PragmaIncludes & getPragmaIncludes() const
Returns the PramaIncludes for preamble + main file includes.
const std::vector< PragmaMark > & getMarks() const
Gets all pragma marks in the main file.
SourceManager & getSourceManager()
ASTContext & getASTContext()
Note that the returned ast will not contain decls from the preamble that were not deserialized during...
const HeuristicResolver * getHeuristicResolver() const
const LangOptions & getLangOpts() const
static std::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::ArrayRef< Diag > getDiagnostics() const
std::shared_ptr< Preprocessor > getPreprocessorPtr()
const syntax::TokenBuffer & getTokens() const
Tokens recorded while parsing the main file.
Preprocessor & getPreprocessor()
ArrayRef< Decl * > getLocalTopLevelDecls()
This function returns top-level decls present in the main file of the AST.
ParsedAST & operator=(ParsedAST &&Other)
const IncludeStructure & getIncludeStructure() const
const SourceManager & getSourceManager() const
ParsedAST(ParsedAST &&Other)
const MainFileMacros & getMacros() const
Gets all macro references (definition, expansions) present in the main file, including those in the p...
std::string Path
A typedef to represent a file path.
llvm::StringRef PathRef
A typedef to represent a ref to file path.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//