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);
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();
128 std::shared_ptr<const PreambleData> Preamble,
129 std::unique_ptr<CompilerInstance> Clang,
130 std::unique_ptr<FrontendAction> Action, syntax::TokenBuffer Tokens,
132 std::vector<Decl *> LocalTopLevelDecls, std::vector<Diag> Diags,
138 std::shared_ptr<const PreambleData>
Preamble;
144 std::unique_ptr<CompilerInstance> Clang;
145 std::unique_ptr<FrontendAction> Action;
150 syntax::TokenBuffer Tokens;
155 std::vector<PragmaMark> Marks;
158 std::vector<Diag> Diags;
161 std::vector<Decl *> LocalTopLevelDecls;
163 include_cleaner::PragmaIncludes PI;
164 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.
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::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...
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++ -*-===//