summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2020-06-15 17:21:58 -0700
committerGitHub <noreply@github.com>2020-06-15 17:21:58 -0700
commit139d0203d520ca589070ad5d5c2d8c08e7d96afe (patch)
tree2bb663453b1e51094fabd8810b536ea074379033 /src
parentd26f90bba43c1672232f51bc90c8194a31aea065 (diff)
downloadbinaryen-139d0203d520ca589070ad5d5c2d8c08e7d96afe.tar.gz
binaryen-139d0203d520ca589070ad5d5c2d8c08e7d96afe.tar.bz2
binaryen-139d0203d520ca589070ad5d5c2d8c08e7d96afe.zip
Add Expression::dump for use while debugging (#2912)
I have found that similar dump functions have been extremely helpful while debugging LLVM. Rather than re-implement this locally whenever I need it, it would be better have this utility upstream.
Diffstat (limited to 'src')
-rw-r--r--src/wasm.h3
-rw-r--r--src/wasm/wasm.cpp8
2 files changed, 11 insertions, 0 deletions
diff --git a/src/wasm.h b/src/wasm.h
index a1c386289..b52e7539b 100644
--- a/src/wasm.h
+++ b/src/wasm.h
@@ -588,6 +588,9 @@ public:
assert(int(_id) == int(T::SpecificId));
return (const T*)this;
}
+
+ // Print the expression to stderr. Meant for use while debugging.
+ void dump();
};
const char* getExpressionName(Expression* curr);
diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp
index 6f86a13ac..f1d51bbca 100644
--- a/src/wasm/wasm.cpp
+++ b/src/wasm/wasm.cpp
@@ -16,6 +16,7 @@
#include "wasm.h"
#include "ir/branch-utils.h"
+#include "wasm-printing.h"
#include "wasm-traversal.h"
namespace wasm {
@@ -93,6 +94,13 @@ Name ATTR("attr");
// Expressions
+void Expression::dump() {
+ WasmPrinter::printExpression(this,
+ std::cerr,
+ /*minify=*/false,
+ /*full=*/true);
+}
+
const char* getExpressionName(Expression* curr) {
switch (curr->_id) {
case Expression::Id::InvalidId: