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"
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"
44class 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; }
115 llvm::StringRef
version()
const {
return Version; }
125 return Resolver.get();
130 std::shared_ptr<const PreambleData> Preamble,
131 std::unique_ptr<CompilerInstance> Clang,
132 std::unique_ptr<FrontendAction> Action, syntax::TokenBuffer Tokens,
134 std::vector<Decl *> LocalTopLevelDecls,
142 std::shared_ptr<const PreambleData>
Preamble;
148 std::unique_ptr<CompilerInstance> Clang;
149 std::unique_ptr<FrontendAction> Action;
154 syntax::TokenBuffer Tokens;
159 std::vector<PragmaMark> Marks;
162 std::optional<std::vector<Diag>> Diags;
165 std::vector<Decl *> LocalTopLevelDecls;
168 std::unique_ptr<HeuristicResolver> Resolver;
const PreambleData & Preamble
std::string Filename
Filename as a string.
std::unique_ptr< CompilerInvocation > CI
Maps a definition location onto an #include file, based on a set of filename rules.
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 std::vector< PragmaMark > & getMarks() const
Gets all pragma marks in the main file.
const include_cleaner::PragmaIncludes * getPragmaIncludes() const
Returns the PramaIncludes from the preamble.
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 std::optional< std::vector< Diag > > & getDiagnostics() const
const LangOptions & getLangOpts() const
const CanonicalIncludes & getCanonicalIncludes() 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.
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++ -*-===//