Coverage Report

Created: 2020-07-11 14:00

/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
0
LLVM_DUMP_METHOD void Function::dump() const { dump(llvm::errs()); }
25
26
0
LLVM_DUMP_METHOD void Function::dump(llvm::raw_ostream &OS) const {
27
0
  if (F) {
28
0
    if (auto *Cons = dyn_cast<CXXConstructorDecl>(F)) {
29
0
      const std::string &Name = Cons->getParent()->getNameAsString();
30
0
      OS << Name << "::" << Name << ":\n";
31
0
    } else {
32
0
      OS << F->getNameAsString() << ":\n";
33
0
    }
34
0
  } else {
35
0
    OS << "<<expr>>\n";
36
0
  }
37
0
38
0
  OS << "frame size: " << getFrameSize() << "\n";
39
0
  OS << "arg size:   " << getArgSize() << "\n";
40
0
  OS << "rvo:        " << hasRVO() << "\n";
41
0
42
0
  auto PrintName = [&OS](const char *Name) {
43
0
    OS << Name;
44
0
    for (long I = 0, N = strlen(Name); I < 30 - N; ++I) {
45
0
      OS << ' ';
46
0
    }
47
0
  };
48
0
49
0
  for (CodePtr Start = getCodeBegin(), PC = Start; PC != getCodeEnd();) {
50
0
    size_t Addr = PC - Start;
51
0
    auto Op = PC.read<Opcode>();
52
0
    OS << llvm::format("%8d", Addr) << " ";
53
0
    switch (Op) {
54
0
#define GET_DISASM
55
0
#include "Opcodes.inc"
56
0
#undef GET_DISASM
57
0
    }
58
0
  }
59
0
}
60
61
0
LLVM_DUMP_METHOD void Program::dump() const { dump(llvm::errs()); }
62
63
0
LLVM_DUMP_METHOD void Program::dump(llvm::raw_ostream &OS) const {
64
0
  for (auto &Func : Funcs) {
65
0
    Func.second->dump();
66
0
  }
67
0
  for (auto &Anon : AnonFuncs) {
68
0
    Anon->dump();
69
0
  }
70
0
}