10 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDUNIT_H 11 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDUNIT_H 18 #include "clang/Frontend/FrontendAction.h" 19 #include "clang/Frontend/PrecompiledPreamble.h" 20 #include "clang/Lex/Preprocessor.h" 21 #include "clang/Serialization/ASTBitCodes.h" 22 #include "clang/Tooling/CompilationDatabase.h" 23 #include "clang/Tooling/Core/Replacement.h" 33 class PCHContainerOperations;
40 struct CompileCommand;
61 IntrusiveRefCntPtr<vfs::FileSystem>
FS;
70 static llvm::Optional<ParsedAST>
71 build(std::unique_ptr<clang::CompilerInvocation> CI,
72 std::shared_ptr<const PreambleData>
Preamble,
73 std::unique_ptr<llvm::MemoryBuffer> Buffer,
74 std::shared_ptr<PCHContainerOperations>
PCHs,
75 IntrusiveRefCntPtr<vfs::FileSystem>
VFS);
85 ASTContext &getASTContext();
86 const ASTContext &getASTContext()
const;
88 Preprocessor &getPreprocessor();
89 std::shared_ptr<Preprocessor> getPreprocessorPtr();
90 const Preprocessor &getPreprocessor()
const;
95 ArrayRef<Decl *> getLocalTopLevelDecls();
97 const std::vector<Diag> &getDiagnostics()
const;
101 std::size_t getUsedBytes()
const;
105 ParsedAST(std::shared_ptr<const PreambleData> Preamble,
106 std::unique_ptr<CompilerInstance> Clang,
107 std::unique_ptr<FrontendAction>
Action,
108 std::vector<Decl *> LocalTopLevelDecls, std::vector<Diag> Diags,
113 std::shared_ptr<const PreambleData>
Preamble;
119 std::unique_ptr<CompilerInstance> Clang;
120 std::unique_ptr<FrontendAction>
Action;
123 std::vector<Diag> Diags;
126 std::vector<Decl *> LocalTopLevelDecls;
131 PathRef Path, ASTContext &, std::shared_ptr<clang::Preprocessor>)>;
134 std::unique_ptr<CompilerInvocation>
143 std::shared_ptr<const PreambleData>
145 std::shared_ptr<const PreambleData> OldPreamble,
146 const tooling::CompileCommand &OldCompileCommand,
148 std::shared_ptr<PCHContainerOperations>
PCHs,
bool StoreInMemory,
154 llvm::Optional<ParsedAST>
157 std::shared_ptr<const PreambleData>
Preamble,
158 std::shared_ptr<PCHContainerOperations>
PCHs);
Some operations such as code completion produce a set of candidates.
std::function< void(PathRef Path, ASTContext &, std::shared_ptr< clang::Preprocessor >)> PreambleParsedCallback
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.
llvm::unique_function< void()> Action
std::string Path
A typedef to represent a file path.
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.
PrecompiledPreamble const * Preamble
IntrusiveRefCntPtr< vfs::FileSystem > VFS
Stores and provides access to parsed AST.
tooling::CompileCommand CompileCommand
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