Author: Timm Bäder Date: 2023-07-20T14:56:44+02:00 New Revision: 3203d3eac4d14f44d6e660d8835c10a42a07fee2
URL: https://github.com/llvm/llvm-project/commit/3203d3eac4d14f44d6e660d8835c10a42a07fee2 DIFF: https://github.com/llvm/llvm-project/commit/3203d3eac4d14f44d6e660d8835c10a42a07fee2.diff LOG: [clang][Interp][NFC] Add InterpStack::dump() Added: Modified: clang/lib/AST/Interp/InterpStack.cpp clang/lib/AST/Interp/InterpStack.h Removed: ################################################################################ diff --git a/clang/lib/AST/Interp/InterpStack.cpp b/clang/lib/AST/Interp/InterpStack.cpp index c5d9a459ce8248..5ca530409c8bf9 100644 --- a/clang/lib/AST/Interp/InterpStack.cpp +++ b/clang/lib/AST/Interp/InterpStack.cpp @@ -6,9 +6,12 @@ // //===----------------------------------------------------------------------===// +#include "InterpStack.h" +#include "Boolean.h" +#include "Floating.h" +#include "Integral.h" #include <cassert> #include <cstdlib> -#include "InterpStack.h" using namespace clang; using namespace clang::interp; @@ -79,3 +82,21 @@ void InterpStack::shrink(size_t Size) { Chunk->End -= Size; StackSize -= Size; } + +void InterpStack::dump() const { +#ifndef NDEBUG + llvm::errs() << "Items: " << ItemTypes.size() << ". Size: " << size() << "\n"; + size_t Index = 0; + size_t Offset = align(primSize(ItemTypes[0])); + for (PrimType Ty : ItemTypes) { + llvm::errs() << Index << "/" << Offset << ": "; + TYPE_SWITCH(Ty, { + const T &V = peek<T>(Offset); + llvm::errs() << V; + }); + llvm::errs() << "\n"; + Offset += align(primSize(Ty)); + ++Index; + } +#endif +} diff --git a/clang/lib/AST/Interp/InterpStack.h b/clang/lib/AST/Interp/InterpStack.h index 14a9b69a557c15..ab4351a6dc679f 100644 --- a/clang/lib/AST/Interp/InterpStack.h +++ b/clang/lib/AST/Interp/InterpStack.h @@ -89,6 +89,9 @@ class InterpStack final { /// Returns whether the stack is empty. bool empty() const { return StackSize == 0; } + /// dump the stack contents to stderr. + void dump() const; + private: /// All stack slots are aligned to the native pointer alignment for storage. /// The size of an object is rounded up to a pointer alignment multiple. _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits