aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/clang/lib/AST/Interp/Disasm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/clang/lib/AST/Interp/Disasm.cpp')
-rw-r--r--contrib/llvm-project/clang/lib/AST/Interp/Disasm.cpp39
1 files changed, 25 insertions, 14 deletions
diff --git a/contrib/llvm-project/clang/lib/AST/Interp/Disasm.cpp b/contrib/llvm-project/clang/lib/AST/Interp/Disasm.cpp
index c1c18f832d4f..d276df8f2926 100644
--- a/contrib/llvm-project/clang/lib/AST/Interp/Disasm.cpp
+++ b/contrib/llvm-project/clang/lib/AST/Interp/Disasm.cpp
@@ -10,6 +10,7 @@
//
//===----------------------------------------------------------------------===//
+#include "Floating.h"
#include "Function.h"
#include "Opcode.h"
#include "PrimType.h"
@@ -21,29 +22,35 @@
using namespace clang;
using namespace clang::interp;
-LLVM_DUMP_METHOD void Function::dump() const { dump(llvm::errs()); }
-
-LLVM_DUMP_METHOD void Function::dump(llvm::raw_ostream &OS) const {
- if (F) {
- if (auto *Cons = dyn_cast<CXXConstructorDecl>(F)) {
- DeclarationName Name = Cons->getParent()->getDeclName();
- OS << Name << "::" << Name << ":\n";
- } else {
- OS << F->getDeclName() << ":\n";
- }
+template <typename T> inline T ReadArg(Program &P, CodePtr &OpPC) {
+ if constexpr (std::is_pointer_v<T>) {
+ uint32_t ID = OpPC.read<uint32_t>();
+ return reinterpret_cast<T>(P.getNativePointer(ID));
} else {
- OS << "<<expr>>\n";
+ return OpPC.read<T>();
}
+}
+template <> inline Floating ReadArg<Floating>(Program &P, CodePtr &OpPC) {
+ Floating F = Floating::deserialize(*OpPC);
+ OpPC += align(F.bytesToSerialize());
+ return F;
+}
+
+LLVM_DUMP_METHOD void Function::dump() const { dump(llvm::errs()); }
+
+LLVM_DUMP_METHOD void Function::dump(llvm::raw_ostream &OS) const {
+ OS << getName() << " " << (const void *)this << "\n";
OS << "frame size: " << getFrameSize() << "\n";
OS << "arg size: " << getArgSize() << "\n";
OS << "rvo: " << hasRVO() << "\n";
+ OS << "this arg: " << hasThisPointer() << "\n";
auto PrintName = [&OS](const char *Name) {
OS << Name;
- for (long I = 0, N = strlen(Name); I < 30 - N; ++I) {
- OS << ' ';
- }
+ long N = 30 - strlen(Name);
+ if (N > 0)
+ OS.indent(N);
};
for (CodePtr Start = getCodeBegin(), PC = Start; PC != getCodeEnd();) {
@@ -61,6 +68,10 @@ LLVM_DUMP_METHOD void Function::dump(llvm::raw_ostream &OS) const {
LLVM_DUMP_METHOD void Program::dump() const { dump(llvm::errs()); }
LLVM_DUMP_METHOD void Program::dump(llvm::raw_ostream &OS) const {
+ OS << ":: Program\n";
+ OS << "Global Variables: " << Globals.size() << "\n";
+ OS << "Functions: " << Funcs.size() << "\n";
+ OS << "\n";
for (auto &Func : Funcs) {
Func.second->dump();
}