aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/clang/lib/AST/Interp/InterpStack.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2023-12-18 20:30:12 +0000
committerDimitry Andric <dim@FreeBSD.org>2024-04-06 20:11:55 +0000
commit5f757f3ff9144b609b3c433dfd370cc6bdc191ad (patch)
tree1b4e980b866cd26a00af34c0a653eb640bd09caf /contrib/llvm-project/clang/lib/AST/Interp/InterpStack.cpp
parent3e1c8a35f741a5d114d0ba670b15191355711fe9 (diff)
parent312c0ed19cc5276a17bacf2120097bec4515b0f1 (diff)
Diffstat (limited to 'contrib/llvm-project/clang/lib/AST/Interp/InterpStack.cpp')
-rw-r--r--contrib/llvm-project/clang/lib/AST/Interp/InterpStack.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/contrib/llvm-project/clang/lib/AST/Interp/InterpStack.cpp b/contrib/llvm-project/clang/lib/AST/Interp/InterpStack.cpp
index da4b36f8c1bf..91fe40feb767 100644
--- a/contrib/llvm-project/clang/lib/AST/Interp/InterpStack.cpp
+++ b/contrib/llvm-project/clang/lib/AST/Interp/InterpStack.cpp
@@ -10,6 +10,7 @@
#include "Boolean.h"
#include "Floating.h"
#include "Integral.h"
+#include "Pointer.h"
#include <cassert>
#include <cstdlib>
@@ -85,20 +86,25 @@ void InterpStack::shrink(size_t Size) {
void InterpStack::dump() const {
#ifndef NDEBUG
- llvm::errs() << "Items: " << ItemTypes.size() << ". Size: " << size() << "\n";
+ llvm::errs() << "Items: " << ItemTypes.size() << ". Size: " << size() << '\n';
if (ItemTypes.empty())
return;
size_t Index = 0;
- size_t Offset = align(primSize(ItemTypes[0]));
- for (PrimType Ty : ItemTypes) {
- llvm::errs() << Index << "/" << Offset << ": ";
- TYPE_SWITCH(Ty, {
+ size_t Offset = 0;
+
+ // The type of the item on the top of the stack is inserted to the back
+ // of the vector, so the iteration has to happen backwards.
+ for (auto TyIt = ItemTypes.rbegin(); TyIt != ItemTypes.rend(); ++TyIt) {
+ Offset += align(primSize(*TyIt));
+
+ llvm::errs() << Index << '/' << Offset << ": ";
+ TYPE_SWITCH(*TyIt, {
const T &V = peek<T>(Offset);
llvm::errs() << V;
});
- llvm::errs() << "\n";
- Offset += align(primSize(Ty));
+ llvm::errs() << '\n';
+
++Index;
}
#endif