diff options
author | Daniel Wirtz <dcode@dcode.io> | 2018-05-09 22:01:18 +0200 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2018-05-09 13:01:18 -0700 |
commit | 6a9ececa2fc9eca99a12b65ca130612942babdce (patch) | |
tree | d1b79577dc98333bc2d5e708633fe71172c594de /src | |
parent | 991974c2049796676a967b5a5d3ffe195e5d818d (diff) | |
download | binaryen-6a9ececa2fc9eca99a12b65ca130612942babdce.tar.gz binaryen-6a9ececa2fc9eca99a12b65ca130612942babdce.tar.bz2 binaryen-6a9ececa2fc9eca99a12b65ca130612942babdce.zip |
Fix MSVC warnings when compiling the binaryen target (#1535)
Diffstat (limited to 'src')
-rw-r--r-- | src/ir/abstract.h | 10 | ||||
-rw-r--r-- | src/passes/CoalesceLocals.cpp | 4 | ||||
-rw-r--r-- | src/passes/OptimizeInstructions.cpp | 2 | ||||
-rw-r--r-- | src/passes/Precompute.cpp | 2 | ||||
-rw-r--r-- | src/passes/Print.cpp | 6 | ||||
-rw-r--r-- | src/passes/RemoveUnusedBrs.cpp | 2 | ||||
-rw-r--r-- | src/wasm/wasm-binary.cpp | 8 | ||||
-rw-r--r-- | src/wasm/wasm-validator.cpp | 8 |
8 files changed, 18 insertions, 24 deletions
diff --git a/src/ir/abstract.h b/src/ir/abstract.h index 3744cb42d..7066d2633 100644 --- a/src/ir/abstract.h +++ b/src/ir/abstract.h @@ -43,16 +43,10 @@ enum Op { inline UnaryOp getUnary(Type type, Op op) { switch (type) { case i32: { - switch (op) { - default: return InvalidUnary; - } - break; + return InvalidUnary; } case i64: { - switch (op) { - default: return InvalidUnary; - } - break; + return InvalidUnary; } case f32: { switch (op) { diff --git a/src/passes/CoalesceLocals.cpp b/src/passes/CoalesceLocals.cpp index e5c5585f4..ef0699436 100644 --- a/src/passes/CoalesceLocals.cpp +++ b/src/passes/CoalesceLocals.cpp @@ -117,7 +117,7 @@ void CoalesceLocals::increaseBackEdgePriorities() { void CoalesceLocals::calculateInterferences() { interferences.resize(numLocals * numLocals); - std::fill(interferences.begin(), interferences.end(), 0); + std::fill(interferences.begin(), interferences.end(), false); for (auto& curr : basicBlocks) { if (liveBlocks.count(curr.get()) == 0) continue; // ignore dead blocks // everything coming in might interfere, as it might come from a different block @@ -207,7 +207,7 @@ void CoalesceLocals::pickIndicesFromOrder(std::vector<Index>& order, std::vector indices.resize(numLocals); types.resize(numLocals); newInterferences.resize(numLocals * numLocals); - std::fill(newInterferences.begin(), newInterferences.end(), 0); + std::fill(newInterferences.begin(), newInterferences.end(), false); auto numParams = getFunction()->getNumParams(); newCopies.resize(numParams * numLocals); // start with enough room for the params std::fill(newCopies.begin(), newCopies.end(), 0); diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp index 6a66ae603..55042d96f 100644 --- a/src/passes/OptimizeInstructions.cpp +++ b/src/passes/OptimizeInstructions.cpp @@ -826,7 +826,7 @@ struct OptimizeInstructions : public WalkerPass<PostWalker<OptimizeInstructions, } else if (auto* ext = Properties::getSignExtValue(binary)) { // if sign extending the exact bit size we store, we can skip the extension // if extending something bigger, then we just alter bits we don't save anyhow - if (Properties::getSignExtBits(binary) >= store->bytes * 8) { + if (Properties::getSignExtBits(binary) >= Index(store->bytes) * 8) { store->value = ext; } } diff --git a/src/passes/Precompute.cpp b/src/passes/Precompute.cpp index 32f54721d..8d6111ab4 100644 --- a/src/passes/Precompute.cpp +++ b/src/passes/Precompute.cpp @@ -224,7 +224,7 @@ private: Flow precomputeExpression(Expression* curr, bool replaceExpression = true) { try { return StandaloneExpressionRunner(getValues, replaceExpression).visit(curr); - } catch (StandaloneExpressionRunner::NonstandaloneException& e) { + } catch (StandaloneExpressionRunner::NonstandaloneException&) { return Flow(NONSTANDALONE_FLOW); } } diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 700ddf734..f894c0d36 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -26,11 +26,11 @@ namespace wasm { -static int isFullForced() { +static bool isFullForced() { if (getenv("BINARYEN_PRINT_FULL")) { - return std::stoi(getenv("BINARYEN_PRINT_FULL")); + return std::stoi(getenv("BINARYEN_PRINT_FULL")) != 0; } - return 0; + return false; } struct PrintSExpression : public Visitor<PrintSExpression> { diff --git a/src/passes/RemoveUnusedBrs.cpp b/src/passes/RemoveUnusedBrs.cpp index 87f53a652..8a80cd3d2 100644 --- a/src/passes/RemoveUnusedBrs.cpp +++ b/src/passes/RemoveUnusedBrs.cpp @@ -756,7 +756,7 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> { auto* c = binary->right->dynCast<Const>(); if (!c) return nullptr; uint32_t value = c->value.geti32(); - if (value >= std::numeric_limits<int32_t>::max()) return nullptr; + if (value >= uint32_t(std::numeric_limits<int32_t>::max())) return nullptr; return br; }; diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index fdcf23622..c36496bfe 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -1621,8 +1621,8 @@ Name WasmBinaryBuilder::getFunctionIndexName(Index i) { void WasmBinaryBuilder::getResizableLimits(Address& initial, Address& max, bool &shared, Address defaultIfNoMax) { auto flags = getU32LEB(); initial = getU32LEB(); - bool hasMax = flags & BinaryConsts::HasMaximum; - bool isShared = flags & BinaryConsts::IsShared; + bool hasMax = (flags & BinaryConsts::HasMaximum) != 0; + bool isShared = (flags & BinaryConsts::IsShared) != 0; if (isShared && !hasMax) throwError("shared memory must have max size"); shared = isShared; if (hasMax) max = getU32LEB(); @@ -1954,7 +1954,7 @@ void WasmBinaryBuilder::readGlobals() { if (debug) std::cerr << "read one" << std::endl; auto type = getConcreteType(); auto mutable_ = getU32LEB(); - if (bool(mutable_) != mutable_) throwError("Global mutability must be 0 or 1"); + if (mutable_ & ~1) throwError("Global mutability must be 0 or 1"); auto* init = readExpression(); wasm.addGlobal(Builder::makeGlobal( "global$" + std::to_string(wasm.globals.size()), @@ -2267,7 +2267,7 @@ BinaryConsts::ASTNodes WasmBinaryBuilder::readExpression(Expression*& curr) { std::cerr << "skipping debug location info for " << nextDebugLocation.first << std::endl; } debugLocation = nextDebugLocation.second; - useDebugLocation = currFunction; // using only for function expressions + useDebugLocation = currFunction != NULL; // using only for function expressions readNextDebugLocation(); } } diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index 2e432b174..07f0a634b 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -494,7 +494,7 @@ void FunctionValidator::visitGetGlobal(GetGlobal* curr) { void FunctionValidator::visitSetGlobal(SetGlobal* curr) { if (!info.validateGlobally) return; auto* global = getModule()->getGlobalOrNull(curr->name); - if (shouldBeTrue(global, curr, "set_global name must be valid (and not an import; imports can't be modified)")) { + if (shouldBeTrue(global != NULL, curr, "set_global name must be valid (and not an import; imports can't be modified)")) { shouldBeTrue(global->mutable_, curr, "set_global global must be mutable"); shouldBeEqualOrFirstIsUnreachable(curr->value->type, global->type, curr, "set_global value must have right type"); } @@ -1031,10 +1031,10 @@ static void validateModule(Module& module, ValidationInfo& info) { // perhaps by moving some of the pass infrastructure into libsupport. bool WasmValidator::validate(Module& module, FeatureSet features, Flags flags) { ValidationInfo info; - info.validateWeb = flags & Web; - info.validateGlobally = flags & Globally; + info.validateWeb = (flags & Web) != 0; + info.validateGlobally = (flags & Globally) != 0; info.features = features; - info.quiet = flags & Quiet; + info.quiet = (flags & Quiet) != 0; // parallel wasm logic validation PassRunner runner(&module); runner.add<FunctionValidator>(&info); |