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/AST/DeclCXX.h"
31#include "clang/Frontend/FrontendAction.h"
32#include "clang/Lex/Preprocessor.h"
33#include "clang/Tooling/Syntax/Tokens.h"
34#include "llvm/ADT/ArrayRef.h"
35#include "llvm/ADT/StringRef.h"
42class HeuristicResolver;
52 static std::optional<ParsedAST>
54 std::unique_ptr<clang::CompilerInvocation> CI,
55 llvm::ArrayRef<Diag> CompilerInvocationDiags,
56 std::shared_ptr<const PreambleData> Preamble);
106 const std::vector<PragmaMark> &
getMarks()
const;
109 const syntax::TokenBuffer &
getTokens()
const {
return Tokens; }
114 llvm::StringRef
version()
const {
return Version; }
124 return Resolver.get();
128 llvm::DenseMap<
const FunctionDecl *,
134 std::shared_ptr<const PreambleData> Preamble,
135 std::unique_ptr<CompilerInstance> Clang,
136 std::unique_ptr<FrontendAction> Action, syntax::TokenBuffer Tokens,
138 std::vector<Decl *> LocalTopLevelDecls, std::vector<Diag> Diags,
144 std::shared_ptr<const PreambleData> Preamble;
150 std::unique_ptr<CompilerInstance> Clang;
151 std::unique_ptr<FrontendAction> Action;
156 syntax::TokenBuffer Tokens;
161 std::vector<PragmaMark> Marks;
164 std::vector<Diag> Diags;
167 std::vector<Decl *> LocalTopLevelDecls;
169 include_cleaner::PragmaIncludes PI;
170 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++ -*-===//