Skip to content

Commit 3451fa5

Browse files
tbaederrchencha3
authored andcommitted
[clang][Interp][NFC] Add InterpFrame::dump()
1 parent c14b181 commit 3451fa5

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

clang/lib/AST/Interp/Disasm.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "FunctionPointer.h"
1717
#include "Integral.h"
1818
#include "IntegralAP.h"
19+
#include "InterpFrame.h"
1920
#include "Opcode.h"
2021
#include "PrimType.h"
2122
#include "Program.h"
@@ -206,3 +207,29 @@ LLVM_DUMP_METHOD void Descriptor::dump(llvm::raw_ostream &OS) const {
206207
if (isDummy())
207208
OS << " dummy";
208209
}
210+
211+
LLVM_DUMP_METHOD void InterpFrame::dump(llvm::raw_ostream &OS,
212+
unsigned Indent) const {
213+
unsigned Spaces = Indent * 2;
214+
{
215+
ColorScope SC(OS, true, {llvm::raw_ostream::BLUE, true});
216+
OS.indent(Spaces);
217+
if (getCallee())
218+
describe(OS);
219+
else
220+
OS << "Frame (Depth: " << getDepth() << ")";
221+
OS << "\n";
222+
}
223+
OS.indent(Spaces) << "Function: " << getFunction();
224+
if (const Function *F = getFunction()) {
225+
OS << " (" << F->getName() << ")";
226+
}
227+
OS << "\n";
228+
OS.indent(Spaces) << "This: " << getThis() << "\n";
229+
OS.indent(Spaces) << "RVO: " << getRVOPtr() << "\n";
230+
231+
while (const InterpFrame *F = this->Caller) {
232+
F->dump(OS, Indent + 1);
233+
F = F->Caller;
234+
}
235+
}

clang/lib/AST/Interp/InterpFrame.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ class InterpFrame final : public Frame {
123123

124124
unsigned getDepth() const { return Depth; }
125125

126+
void dump() const { dump(llvm::errs(), 0); }
127+
void dump(llvm::raw_ostream &OS, unsigned Indent = 0) const;
128+
126129
private:
127130
/// Returns an original argument from the stack.
128131
template <typename T> const T &stackRef(unsigned Offset) const {

0 commit comments

Comments
 (0)