summaryrefslogtreecommitdiffstats
path: root/clangd/Compiler.h
diff options
context:
space:
mode:
Diffstat (limited to 'clangd/Compiler.h')
-rw-r--r--clangd/Compiler.h33
1 files changed, 27 insertions, 6 deletions
diff --git a/clangd/Compiler.h b/clangd/Compiler.h
index 7a3c43d6..c24ea354 100644
--- a/clangd/Compiler.h
+++ b/clangd/Compiler.h
@@ -1,9 +1,8 @@
//===--- Compiler.h ----------------------------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
@@ -16,9 +15,12 @@
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_COMPILER_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_COMPILER_H
+#include "../clang-tidy/ClangTidyOptions.h"
+#include "GlobalCompilationDatabase.h"
+#include "index/Index.h"
#include "clang/Frontend/CompilerInstance.h"
-#include "clang/Frontend/CompilerInvocation.h"
#include "clang/Frontend/PrecompiledPreamble.h"
+#include "clang/Tooling/CompilationDatabase.h"
namespace clang {
namespace clangd {
@@ -32,6 +34,26 @@ public:
const clang::Diagnostic &Info) override;
};
+// Options to run clang e.g. when parsing AST.
+struct ParseOptions {
+ tidy::ClangTidyOptions ClangTidyOpts;
+ bool SuggestMissingIncludes = false;
+};
+
+/// Information required to run clang, e.g. to parse AST or do code completion.
+struct ParseInputs {
+ tooling::CompileCommand CompileCommand;
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS;
+ std::string Contents;
+ // Used to recover from diagnostics (e.g. find missing includes for symbol).
+ const SymbolIndex *Index = nullptr;
+ ParseOptions Opts;
+};
+
+/// Builds compiler invocation that could be used to build AST or preamble.
+std::unique_ptr<CompilerInvocation>
+buildCompilerInvocation(const ParseInputs &Inputs);
+
/// Creates a compiler instance, configured so that:
/// - Contents of the parsed file are remapped to \p MainFile.
/// - Preamble is overriden to use PCH passed to this function. It means the
@@ -45,7 +67,6 @@ public:
std::unique_ptr<CompilerInstance> prepareCompilerInstance(
std::unique_ptr<clang::CompilerInvocation>, const PrecompiledPreamble *,
std::unique_ptr<llvm::MemoryBuffer> MainFile,
- std::shared_ptr<PCHContainerOperations>,
IntrusiveRefCntPtr<llvm::vfs::FileSystem>, DiagnosticConsumer &);
} // namespace clangd