Coverage Report

Created: 2021-09-21 08:58

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/include/clang/Interpreter/Interpreter.h
Line
Count
Source (jump to first uncovered line)
1
//===--- Interpreter.h - Incremental Compilation and Execution---*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This file defines the component which performs incremental code
10
// compilation and execution.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_CLANG_INTERPRETER_INTERPRETER_H
15
#define LLVM_CLANG_INTERPRETER_INTERPRETER_H
16
17
#include "clang/Interpreter/PartialTranslationUnit.h"
18
19
#include "llvm/Support/Error.h"
20
21
#include <memory>
22
#include <vector>
23
24
namespace llvm {
25
namespace orc {
26
class ThreadSafeContext;
27
}
28
class Module;
29
} // namespace llvm
30
31
namespace clang {
32
33
class CompilerInstance;
34
class DeclGroupRef;
35
class IncrementalExecutor;
36
class IncrementalParser;
37
38
/// Create a pre-configured \c CompilerInstance for incremental processing.
39
class IncrementalCompilerBuilder {
40
public:
41
  static llvm::Expected<std::unique_ptr<CompilerInstance>>
42
  create(std::vector<const char *> &ClangArgv);
43
};
44
45
/// Provides top-level interfaces for incremental compilation and execution.
46
class Interpreter {
47
  std::unique_ptr<llvm::orc::ThreadSafeContext> TSCtx;
48
  std::unique_ptr<IncrementalParser> IncrParser;
49
  std::unique_ptr<IncrementalExecutor> IncrExecutor;
50
51
  Interpreter(std::unique_ptr<CompilerInstance> CI, llvm::Error &Err);
52
53
public:
54
  ~Interpreter();
55
  static llvm::Expected<std::unique_ptr<Interpreter>>
56
  create(std::unique_ptr<CompilerInstance> CI);
57
  const CompilerInstance *getCompilerInstance() const;
58
  llvm::Expected<PartialTranslationUnit &> Parse(llvm::StringRef Code);
59
  llvm::Error Execute(PartialTranslationUnit &T);
60
35
  llvm::Error ParseAndExecute(llvm::StringRef Code) {
61
35
    auto PTU = Parse(Code);
62
35
    if (!PTU)
63
0
      return PTU.takeError();
64
35
    if (PTU->TheModule)
65
18
      return Execute(*PTU);
66
17
    return llvm::Error::success();
67
35
  }
68
};
69
} // namespace clang
70
71
#endif // LLVM_CLANG_INTERPRETER_INTERPRETER_H