summaryrefslogtreecommitdiff
path: root/src/asm2wasm.h
diff options
context:
space:
mode:
authorJF Bastien <jfb@chromium.org>2016-01-10 10:49:59 -0800
committerJF Bastien <jfb@chromium.org>2016-01-10 17:40:15 -0800
commite3c38c14e7dd9c115da960daafd109d2687f1a08 (patch)
treec8e892eed8ad9dc0a5e071b9e8af775733dedc03 /src/asm2wasm.h
parent75a562190a9f4588c8ffb19b8304f76c15a850c6 (diff)
downloadbinaryen-e3c38c14e7dd9c115da960daafd109d2687f1a08.tar.gz
binaryen-e3c38c14e7dd9c115da960daafd109d2687f1a08.tar.bz2
binaryen-e3c38c14e7dd9c115da960daafd109d2687f1a08.zip
Add Travis builds with sanitizers
This triggers 5 independent build / test runs: - clang, no sanitizer; - clang, UB sanitizer; - clang, address sanitizer (disabled for now); - clang, thread sanitizer (disabled for now); - GCC. Enabling UBSan led to these changes: - Fix a bunch of undefined behavior throughout the code base. - Fix some tests that relied on that undefined behavior. - Make some of the tests easier to debug by printing their command line. - Add ubsan blacklist to work around libstdc++ bug. - Example testcase also needs sanitizer because libsupport.a uses it.
Diffstat (limited to 'src/asm2wasm.h')
-rw-r--r--src/asm2wasm.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h
index db7cc1ae0..c72c7e98a 100644
--- a/src/asm2wasm.h
+++ b/src/asm2wasm.h
@@ -385,7 +385,7 @@ private:
}
if (ast[1] == MINUS && ast[2][0] == NUM) {
double num = -ast[2][1]->getNumber();
- assert(isInteger32(num));
+ assert(isSInteger32(num));
return Literal((int32_t)num);
}
if (ast[1] == PLUS && ast[2][0] == UNARY_PREFIX && ast[2][1] == MINUS && ast[2][2][0] == NUM) {
@@ -912,9 +912,12 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
} else if (what == NUM) {
auto ret = allocator.alloc<Const>();
double num = ast[1]->getNumber();
- if (isInteger32(num)) {
+ if (isSInteger32(num)) {
ret->value.type = WasmType::i32;
- ret->value.i32 = toInteger32(num);
+ ret->value.i32 = toSInteger32(num);
+ } else if (isUInteger32(num)) {
+ ret->value.type = WasmType::i32;
+ ret->value.i32 = toUInteger32(num);
} else {
ret->value.type = WasmType::f64;
ret->value.f64 = num;