summaryrefslogtreecommitdiff
path: root/src/emscripten-optimizer/parser.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/emscripten-optimizer/parser.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/emscripten-optimizer/parser.h')
-rw-r--r--src/emscripten-optimizer/parser.h18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/emscripten-optimizer/parser.h b/src/emscripten-optimizer/parser.h
index c805ca9f6..da3e6f5c7 100644
--- a/src/emscripten-optimizer/parser.h
+++ b/src/emscripten-optimizer/parser.h
@@ -22,13 +22,14 @@
#ifndef wasm_parser_h
#define wasm_parser_h
-#include <vector>
-#include <iostream>
#include <algorithm>
-
-#include <stdio.h>
+#include <cstdio>
+#include <iostream>
+#include <limits>
+#include <vector>
#include "istring.h"
+#include "support/safe_integer.h"
namespace cashew {
@@ -179,10 +180,6 @@ class Parser {
static bool hasChar(const char* list, char x) { while (*list) if (*list++ == x) return true; return false; }
- static bool is32Bit(double x) {
- return x == (int)x || x == (unsigned int)x;
- }
-
// An atomic fragment of something. Stops at a natural boundary.
enum FragType {
KEYWORD = 0,
@@ -249,7 +246,10 @@ class Parser {
// for valid asm.js input, the '.' should be enough, and for uglify
// in the emscripten optimizer pipeline, we use simple_ast where INT/DOUBLE
// is quite the same at this point anyhow
- type = (std::find(start, src, '.') == src && is32Bit(num)) ? INT : DOUBLE;
+ type = (std::find(start, src, '.') == src &&
+ (wasm::isSInteger32(num) || wasm::isUInteger32(num)))
+ ? INT
+ : DOUBLE;
assert(src > start);
} else if (hasChar(OPERATOR_INITS, *src)) {
switch (*src) {