comparison clang-tools-extra/clangd/Compiler.h @ 221:79ff65ed7e25

LLVM12 Original
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 15 Jun 2021 19:15:29 +0900
parents 0572611fdcc8
children c4bab56944e8
comparison
equal deleted inserted replaced
220:42394fc6a535 221:79ff65ed7e25
13 //===----------------------------------------------------------------------===// 13 //===----------------------------------------------------------------------===//
14 14
15 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_COMPILER_H 15 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_COMPILER_H
16 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_COMPILER_H 16 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_COMPILER_H
17 17
18 #include "../clang-tidy/ClangTidyOptions.h" 18 #include "FeatureModule.h"
19 #include "GlobalCompilationDatabase.h" 19 #include "GlobalCompilationDatabase.h"
20 #include "TidyProvider.h"
20 #include "index/Index.h" 21 #include "index/Index.h"
22 #include "support/ThreadsafeFS.h"
21 #include "clang/Frontend/CompilerInstance.h" 23 #include "clang/Frontend/CompilerInstance.h"
22 #include "clang/Frontend/PrecompiledPreamble.h" 24 #include "clang/Frontend/PrecompiledPreamble.h"
23 #include "clang/Tooling/CompilationDatabase.h" 25 #include "clang/Tooling/CompilationDatabase.h"
26 #include <memory>
27 #include <vector>
24 28
25 namespace clang { 29 namespace clang {
26 namespace clangd { 30 namespace clangd {
27 31
28 class IgnoreDiagnostics : public DiagnosticConsumer { 32 class IgnoreDiagnostics : public DiagnosticConsumer {
34 const clang::Diagnostic &Info) override; 38 const clang::Diagnostic &Info) override;
35 }; 39 };
36 40
37 // Options to run clang e.g. when parsing AST. 41 // Options to run clang e.g. when parsing AST.
38 struct ParseOptions { 42 struct ParseOptions {
39 tidy::ClangTidyOptions ClangTidyOpts; 43 // (empty at present, formerly controlled recovery AST, include-fixer etc)
40 bool SuggestMissingIncludes = false;
41 bool BuildRecoveryAST = false;
42 bool PreserveRecoveryASTType = false;
43 }; 44 };
44 45
45 /// Information required to run clang, e.g. to parse AST or do code completion. 46 /// Information required to run clang, e.g. to parse AST or do code completion.
46 struct ParseInputs { 47 struct ParseInputs {
47 tooling::CompileCommand CompileCommand; 48 tooling::CompileCommand CompileCommand;
48 IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS; 49 const ThreadsafeFS *TFS;
49 std::string Contents; 50 std::string Contents;
50 // Version identifier for Contents, provided by the client and opaque to us. 51 // Version identifier for Contents, provided by the client and opaque to us.
51 std::string Version = "null"; 52 std::string Version = "null";
52 // Prevent reuse of the cached preamble/AST. Slow! Useful to workaround 53 // Prevent reuse of the cached preamble/AST. Slow! Useful to workaround
53 // clangd's assumption that missing header files will stay missing. 54 // clangd's assumption that missing header files will stay missing.
54 bool ForceRebuild = false; 55 bool ForceRebuild = false;
55 // Used to recover from diagnostics (e.g. find missing includes for symbol). 56 // Used to recover from diagnostics (e.g. find missing includes for symbol).
56 const SymbolIndex *Index = nullptr; 57 const SymbolIndex *Index = nullptr;
57 ParseOptions Opts; 58 ParseOptions Opts = ParseOptions();
59 TidyProviderRef ClangTidyProvider = {};
60 // Used to acquire ASTListeners when parsing files.
61 FeatureModuleSet *FeatureModules = nullptr;
58 }; 62 };
59 63
60 /// Builds compiler invocation that could be used to build AST or preamble. 64 /// Builds compiler invocation that could be used to build AST or preamble.
61 std::unique_ptr<CompilerInvocation> 65 std::unique_ptr<CompilerInvocation>
62 buildCompilerInvocation(const ParseInputs &Inputs, clang::DiagnosticConsumer &D, 66 buildCompilerInvocation(const ParseInputs &Inputs, clang::DiagnosticConsumer &D,