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"
41class 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);
105 const std::vector<PragmaMark> &
getMarks()
const;
108 const syntax::TokenBuffer &
getTokens()
const {
return Tokens; }
113 llvm::StringRef
version()
const {
return Version; }
123 return Resolver.get();
127 llvm::DenseMap<
const FunctionDecl *,
128 SmallVector<const CXXConstructorDecl *, 1>>
133 std::shared_ptr<const PreambleData> Preamble,
134 std::unique_ptr<CompilerInstance> Clang,
135 std::unique_ptr<FrontendAction> Action, syntax::TokenBuffer Tokens,
137 std::vector<Decl *> LocalTopLevelDecls, std::vector<Diag> Diags,
143 std::shared_ptr<const PreambleData> Preamble;
149 std::unique_ptr<CompilerInstance> Clang;
150 std::unique_ptr<FrontendAction> Action;
155 syntax::TokenBuffer Tokens;
160 std::vector<PragmaMark> Marks;
163 std::vector<Diag> Diags;
166 std::vector<Decl *> LocalTopLevelDecls;
168 include_cleaner::PragmaIncludes PI;
169 std::unique_ptr<HeuristicResolver> Resolver;
ParsedAST & operator=(const ParsedAST &Other)=delete
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::DenseMap< const FunctionDecl *, SmallVector< const CXXConstructorDecl *, 1 > > ForwardingToConstructorCache
Cache for constructors called through forwarding, e.g. make_unique.
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.
ParsedAST(const ParsedAST &Other)=delete
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...
FIXME: Skip testing on windows temporarily due to the different escaping code mode.
llvm::StringRef PathRef
A typedef to represent a ref to file path.
std::string Path
A typedef to represent a file path.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//