Coverage Report

Created: 2021-09-21 08:58

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/AST/Interp/Disasm.cpp
Line
Count
Source (jump to first uncovered line)
1
//===--- Disasm.cpp - Disassembler for bytecode functions -------*- 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
// Dump method for Function which disassembles the bytecode.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "Function.h"
14
#include "Opcode.h"
15
#include "PrimType.h"
16
#include "Program.h"
17
#include "clang/AST/DeclCXX.h"
18
#include "llvm/Support/Compiler.h"
19
#include "llvm/Support/Format.h"
20
21
using namespace clang;
22
using namespace clang::interp;
23
24
template <typename T>
25
inline std::enable_if_t<!std::is_pointer<T>::value, T> ReadArg(Program &P,
26
0
                                                               CodePtr OpPC) {
27
0
  return OpPC.read<T>();
28
0
}
Unexecuted instantiation: std::__1::enable_if<!(std::is_pointer<bool>::value), bool>::type ReadArg<bool>(clang::interp::Program&, clang::interp::CodePtr)
Unexecuted instantiation: std::__1::enable_if<!(std::is_pointer<short>::value), short>::type ReadArg<short>(clang::interp::Program&, clang::interp::CodePtr)
Unexecuted instantiation: std::__1::enable_if<!(std::is_pointer<int>::value), int>::type ReadArg<int>(clang::interp::Program&, clang::interp::CodePtr)
Unexecuted instantiation: std::__1::enable_if<!(std::is_pointer<long long>::value), long long>::type ReadArg<long long>(clang::interp::Program&, clang::interp::CodePtr)
Unexecuted instantiation: std::__1::enable_if<!(std::is_pointer<signed char>::value), signed char>::type ReadArg<signed char>(clang::interp::Program&, clang::interp::CodePtr)
Unexecuted instantiation: std::__1::enable_if<!(std::is_pointer<unsigned short>::value), unsigned short>::type ReadArg<unsigned short>(clang::interp::Program&, clang::interp::CodePtr)
Unexecuted instantiation: std::__1::enable_if<!(std::is_pointer<unsigned int>::value), unsigned int>::type ReadArg<unsigned int>(clang::interp::Program&, clang::interp::CodePtr)
Unexecuted instantiation: std::__1::enable_if<!(std::is_pointer<unsigned long long>::value), unsigned long long>::type ReadArg<unsigned long long>(clang::interp::Program&, clang::interp::CodePtr)
Unexecuted instantiation: std::__1::enable_if<!(std::is_pointer<unsigned char>::value), unsigned char>::type ReadArg<unsigned char>(clang::interp::Program&, clang::interp::CodePtr)
29
30
template <typename T>
31
inline std::enable_if_t<std::is_pointer<T>::value, T> ReadArg(Program &P,
32
0
                                                              CodePtr OpPC) {
33
0
  uint32_t ID = OpPC.read<uint32_t>();
34
0
  return reinterpret_cast<T>(P.getNativePointer(ID));
35
0
}
Unexecuted instantiation: std::__1::enable_if<std::is_pointer<clang::RecordDecl const*>::value, clang::RecordDecl const*>::type ReadArg<clang::RecordDecl const*>(clang::interp::Program&, clang::interp::CodePtr)
Unexecuted instantiation: std::__1::enable_if<std::is_pointer<clang::interp::Record::Field const*>::value, clang::interp::Record::Field const*>::type ReadArg<clang::interp::Record::Field const*>(clang::interp::Program&, clang::interp::CodePtr)
36
37
0
LLVM_DUMP_METHOD void Function::dump() const { dump(llvm::errs()); }
38
39
0
LLVM_DUMP_METHOD void Function::dump(llvm::raw_ostream &OS) const {
40
0
  if (F) {
41
0
    if (auto *Cons = dyn_cast<CXXConstructorDecl>(F)) {
42
0
      DeclarationName Name = Cons->getParent()->getDeclName();
43
0
      OS << Name << "::" << Name << ":\n";
44
0
    } else {
45
0
      OS << F->getDeclName() << ":\n";
46
0
    }
47
0
  } else {
48
0
    OS << "<<expr>>\n";
49
0
  }
50
51
0
  OS << "frame size: " << getFrameSize() << "\n";
52
0
  OS << "arg size:   " << getArgSize() << "\n";
53
0
  OS << "rvo:        " << hasRVO() << "\n";
54
55
0
  auto PrintName = [&OS](const char *Name) {
56
0
    OS << Name;
57
0
    for (long I = 0, N = strlen(Name); I < 30 - N; ++I) {
58
0
      OS << ' ';
59
0
    }
60
0
  };
61
62
0
  for (CodePtr Start = getCodeBegin(), PC = Start; PC != getCodeEnd();) {
63
0
    size_t Addr = PC - Start;
64
0
    auto Op = PC.read<Opcode>();
65
0
    OS << llvm::format("%8d", Addr) << " ";
66
0
    switch (Op) {
67
0
#define GET_DISASM
68
0
#include "Opcodes.inc"
69
0
#undef GET_DISASM
70
0
    }
71
0
  }
72
0
}
73
74
0
LLVM_DUMP_METHOD void Program::dump() const { dump(llvm::errs()); }
75
76
0
LLVM_DUMP_METHOD void Program::dump(llvm::raw_ostream &OS) const {
77
0
  for (auto &Func : Funcs) {
78
0
    Func.second->dump();
79
0
  }
80
0
  for (auto &Anon : AnonFuncs) {
81
0
    Anon->dump();
82
0
  }
83
0
}