10 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDUNIT_H 11 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDUNIT_H 19 #include "clang/Frontend/FrontendAction.h" 20 #include "clang/Frontend/PrecompiledPreamble.h" 21 #include "clang/Lex/Preprocessor.h" 22 #include "clang/Serialization/ASTBitCodes.h" 23 #include "clang/Tooling/CompilationDatabase.h" 24 #include "clang/Tooling/Core/Replacement.h" 38 class PCHContainerOperations;
41 struct CompileCommand;
50 std::unique_ptr<PreambleFileStatusCache> StatCache);
66 IntrusiveRefCntPtr<llvm::vfs::FileSystem>
FS;
75 static llvm::Optional<ParsedAST>
76 build(std::unique_ptr<clang::CompilerInvocation> CI,
77 std::shared_ptr<const PreambleData>
Preamble,
78 std::unique_ptr<llvm::MemoryBuffer> Buffer,
79 std::shared_ptr<PCHContainerOperations>
PCHs,
80 IntrusiveRefCntPtr<llvm::vfs::FileSystem>
VFS);
90 ASTContext &getASTContext();
91 const ASTContext &getASTContext()
const;
93 Preprocessor &getPreprocessor();
94 std::shared_ptr<Preprocessor> getPreprocessorPtr();
95 const Preprocessor &getPreprocessor()
const;
100 ArrayRef<Decl *> getLocalTopLevelDecls();
102 const std::vector<Diag> &getDiagnostics()
const;
106 std::size_t getUsedBytes()
const;
110 ParsedAST(std::shared_ptr<const PreambleData> Preamble,
111 std::unique_ptr<CompilerInstance> Clang,
112 std::unique_ptr<FrontendAction>
Action,
113 std::vector<Decl *> LocalTopLevelDecls, std::vector<Diag> Diags,
118 std::shared_ptr<const PreambleData>
Preamble;
124 std::unique_ptr<CompilerInstance> Clang;
125 std::unique_ptr<FrontendAction>
Action;
128 std::vector<Diag> Diags;
131 std::vector<Decl *> LocalTopLevelDecls;
136 std::function<void(ASTContext &, std::shared_ptr<clang::Preprocessor>)>;
139 std::unique_ptr<CompilerInvocation>
148 std::shared_ptr<const PreambleData>
150 std::shared_ptr<const PreambleData> OldPreamble,
151 const tooling::CompileCommand &OldCompileCommand,
153 std::shared_ptr<PCHContainerOperations>
PCHs,
bool StoreInMemory,
159 llvm::Optional<ParsedAST>
162 std::shared_ptr<const PreambleData>
Preamble,
163 std::shared_ptr<PCHContainerOperations>
PCHs);
177 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDUNIT_H Some operations such as code completion produce a set of candidates.
llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > VFS
llvm::Optional< ParsedAST > buildAST(PathRef FileName, std::unique_ptr< CompilerInvocation > Invocation, const ParseInputs &Inputs, std::shared_ptr< const PreambleData > Preamble, std::shared_ptr< PCHContainerOperations > PCHs)
Build an AST from provided user inputs.
void dumpAST(ParsedAST &AST, llvm::raw_ostream &OS)
For testing/debugging purposes.
llvm::StringRef PathRef
A typedef to represent a ref to file path.
std::function< void(ASTContext &, std::shared_ptr< clang::Preprocessor >)> PreambleParsedCallback
std::unique_ptr< PreambleFileStatusCache > StatCache
llvm::unique_function< void()> Action
std::unique_ptr< CompilerInvocation > buildCompilerInvocation(const ParseInputs &Inputs)
Builds compiler invocation that could be used to build AST or preamble.
std::shared_ptr< const PreambleData > buildPreamble(PathRef FileName, CompilerInvocation &CI, std::shared_ptr< const PreambleData > OldPreamble, const tooling::CompileCommand &OldCompileCommand, const ParseInputs &Inputs, std::shared_ptr< PCHContainerOperations > PCHs, bool StoreInMemory, PreambleParsedCallback PreambleCallback)
Rebuild the preamble for the new inputs unless the old one can be reused.
Stores and provides access to parsed AST.
tooling::CompileCommand CompileCommand
const PreambleData * Preamble
SourceLocation getBeginningOfIdentifier(ParsedAST &Unit, const Position &Pos, const FileID FID)
Get the beginning SourceLocation at a specified Pos.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
std::shared_ptr< PCHContainerOperations > PCHs
std::vector< Diag > Diags
PrecompiledPreamble Preamble
IncludeStructure Includes