Coverage Report

Created: 2022-07-16 07:03

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/AST/Interp/Function.cpp
Line
Count
Source (jump to first uncovered line)
1
//===--- Function.h - Bytecode function for the VM --------------*- 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
#include "Function.h"
10
#include "Program.h"
11
#include "Opcode.h"
12
#include "clang/AST/Decl.h"
13
#include "clang/AST/DeclCXX.h"
14
15
using namespace clang;
16
using namespace clang::interp;
17
18
Function::Function(Program &P, const FunctionDecl *F, unsigned ArgSize,
19
                   llvm::SmallVector<PrimType, 8> &&ParamTypes,
20
                   llvm::DenseMap<unsigned, ParamDescriptor> &&Params)
21
    : P(P), Loc(F->getBeginLoc()), F(F), ArgSize(ArgSize),
22
2
      ParamTypes(std::move(ParamTypes)), Params(std::move(Params)) {}
23
24
1
CodePtr Function::getCodeBegin() const { return Code.data(); }
25
26
0
CodePtr Function::getCodeEnd() const { return Code.data() + Code.size(); }
27
28
0
Function::ParamDescriptor Function::getParamDescriptor(unsigned Offset) const {
29
0
  auto It = Params.find(Offset);
30
0
  assert(It != Params.end() && "Invalid parameter offset");
31
0
  return It->second;
32
0
}
33
34
0
SourceInfo Function::getSource(CodePtr PC) const {
35
0
  unsigned Offset = PC - getCodeBegin();
36
0
  using Elem = std::pair<unsigned, SourceInfo>;
37
0
  auto It = llvm::lower_bound(SrcMap, Elem{Offset, {}}, llvm::less_first());
38
0
  if (It == SrcMap.end() || It->first != Offset)
39
0
    llvm::report_fatal_error("missing source location");
40
0
  return It->second;
41
0
}
42
43
0
bool Function::isVirtual() const {
44
0
  if (auto *M = dyn_cast<CXXMethodDecl>(F))
45
0
    return M->isVirtual();
46
0
  return false;
47
0
}