Skip to content

Commit

Permalink
[clang][Interp][NFC] Add InterpFrame::dump()
Browse files Browse the repository at this point in the history
  • Loading branch information
tbaederr committed Mar 19, 2024
1 parent 1a6953a commit 0d40de7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
27 changes: 27 additions & 0 deletions clang/lib/AST/Interp/Disasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "FunctionPointer.h"
#include "Integral.h"
#include "IntegralAP.h"
#include "InterpFrame.h"
#include "Opcode.h"
#include "PrimType.h"
#include "Program.h"
Expand Down Expand Up @@ -206,3 +207,29 @@ LLVM_DUMP_METHOD void Descriptor::dump(llvm::raw_ostream &OS) const {
if (isDummy())
OS << " dummy";
}

LLVM_DUMP_METHOD void InterpFrame::dump(llvm::raw_ostream &OS,
unsigned Indent) const {
unsigned Spaces = Indent * 2;
{
ColorScope SC(OS, true, {llvm::raw_ostream::BLUE, true});
OS.indent(Spaces);
if (getCallee())
describe(OS);
else
OS << "Frame (Depth: " << getDepth() << ")";
OS << "\n";
}
OS.indent(Spaces) << "Function: " << getFunction();
if (const Function *F = getFunction()) {
OS << " (" << F->getName() << ")";
}
OS << "\n";
OS.indent(Spaces) << "This: " << getThis() << "\n";
OS.indent(Spaces) << "RVO: " << getRVOPtr() << "\n";

while (const InterpFrame *F = this->Caller) {
F->dump(OS, Indent + 1);
F = F->Caller;
}
}
3 changes: 3 additions & 0 deletions clang/lib/AST/Interp/InterpFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ class InterpFrame final : public Frame {

unsigned getDepth() const { return Depth; }

void dump() const { dump(llvm::errs(), 0); }
void dump(llvm::raw_ostream &OS, unsigned Indent = 0) const;

private:
/// Returns an original argument from the stack.
template <typename T> const T &stackRef(unsigned Offset) const {
Expand Down

0 comments on commit 0d40de7

Please sign in to comment.