clang-tools  7.0.0
Compiler.h
Go to the documentation of this file.
1 //===--- Compiler.h ---------------------------------------------*- C++-*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===---------------------------------------------------------------------===//
9 //
10 // Shared utilities for invoking the clang compiler.
11 // ClangdUnit takes care of much of this, but some features like CodeComplete
12 // run their own compile actions that share logic.
13 //
14 //===---------------------------------------------------------------------===//
15 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_COMPILER_H
16 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_COMPILER_H
17 
18 #include "clang/Frontend/CompilerInstance.h"
19 #include "clang/Frontend/CompilerInvocation.h"
20 #include "clang/Frontend/PrecompiledPreamble.h"
21 
22 namespace clang {
23 namespace clangd {
24 
26 public:
27  static void log(DiagnosticsEngine::Level DiagLevel,
28  const clang::Diagnostic &Info);
29 
30  void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
31  const clang::Diagnostic &Info) override;
32 };
33 
34 /// Creates a compiler instance, configured so that:
35 /// - Contents of the parsed file are remapped to \p MainFile.
36 /// - Preamble is overriden to use PCH passed to this function. It means the
37 /// changes to the preamble headers or files included in the preamble are
38 /// not visible to this compiler instance.
39 /// - vfs::FileSystem is used for all underlying file accesses. The actual
40 /// vfs used by the compiler may be an overlay over the passed vfs.
41 /// Returns null on errors. When non-null value is returned, it is expected to
42 /// be consumed by FrontendAction::BeginSourceFile to properly destroy \p
43 /// MainFile.
44 std::unique_ptr<CompilerInstance> prepareCompilerInstance(
45  std::unique_ptr<clang::CompilerInvocation>, const PrecompiledPreamble *,
46  std::unique_ptr<llvm::MemoryBuffer> MainFile,
47  std::shared_ptr<PCHContainerOperations>,
48  IntrusiveRefCntPtr<vfs::FileSystem>, DiagnosticConsumer &);
49 
50 } // namespace clangd
51 } // namespace clang
52 
53 #endif
static void log(DiagnosticsEngine::Level DiagLevel, const clang::Diagnostic &Info)
Definition: Compiler.cpp:20
FunctionInfo Info
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
std::unique_ptr< CompilerInstance > prepareCompilerInstance(std::unique_ptr< clang::CompilerInvocation > CI, const PrecompiledPreamble *Preamble, std::unique_ptr< llvm::MemoryBuffer > Buffer, std::shared_ptr< PCHContainerOperations > PCHs, IntrusiveRefCntPtr< vfs::FileSystem > VFS, DiagnosticConsumer &DiagsClient)
Creates a compiler instance, configured so that:
Definition: Compiler.cpp:43
void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, const clang::Diagnostic &Info) override
Definition: Compiler.cpp:37