From: Brian Sullivan Date: Mon, 20 Apr 2015 23:36:14 +0000 (-0700) Subject: Removed the -Wno-switch compiler option for the Clang builds on Linux X-Git-Tag: accepted/tizen/base/20180629.140029~6760^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8201dd51434fa803a3d32e6bafb3175f18fb2329;p=platform%2Fupstream%2Fcoreclr.git Removed the -Wno-switch compiler option for the Clang builds on Linux Fix all these warnings in the JIT that were disabled by the -Wno-switch option Fix the two new warnings in Strike/strike.cpp --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 5381f02..a769dc9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -276,9 +276,6 @@ add_compile_options(-Wno-implicit-exception-spec-mismatch) # class, but different set of parameters. add_compile_options(-Wno-overloaded-virtual) add_compile_options(-Wno-unused-variable) -# Enum value is not handled in a switch (and there is no default clause) -# Remaining cases are in JIT only -add_compile_options(-Wno-switch) # Explicit constructor calls are not supported by clang (this->ClassName::ClassName()) add_compile_options(-Wno-microsoft) # This warning is caused by comparing 'this' to NULL diff --git a/src/ToolBox/SOS/Strike/strike.cpp b/src/ToolBox/SOS/Strike/strike.cpp index 5a175cf..6e944f7 100644 --- a/src/ToolBox/SOS/Strike/strike.cpp +++ b/src/ToolBox/SOS/Strike/strike.cpp @@ -10654,6 +10654,10 @@ private: case ELEMENT_TYPE_PTR: wcsncat_s(typeName, typeNameLen, W("*\0"), typeNameLen); return S_OK; + default: + // note we can never reach here as this is a nested switch + // and corElemType can only be one of the values above + break; } } break; @@ -10879,6 +10883,8 @@ private: printed = true; } break; + default: + break; } } } @@ -13947,4 +13953,4 @@ Help(PDEBUG_CLIENT Client, PCSTR Args) return S_OK; } -#endif // !FEATURE_PAL \ No newline at end of file +#endif // !FEATURE_PAL diff --git a/src/jit/assertionprop.cpp b/src/jit/assertionprop.cpp index 409fc64..fccec98 100644 --- a/src/jit/assertionprop.cpp +++ b/src/jit/assertionprop.cpp @@ -1449,6 +1449,10 @@ void Compiler::optDebugCheckAssertions(unsigned index) } } break; + + default: + // for all other 'assertion->op2.kind' values we don't check anything + break; } } } @@ -1743,7 +1747,7 @@ void Compiler::optAssertionGen(GenTreePtr tree) // For most of the assertions that we create below // the assertion is true after the tree is processed bool assertionProven = true; - unsigned assertionIndex = 0; + unsigned assertionIndex = NO_ASSERTION_INDEX; switch (tree->gtOper) { case GT_ASG: @@ -1814,6 +1818,10 @@ void Compiler::optAssertionGen(GenTreePtr tree) case GT_JTRUE: assertionIndex = optAssertionGenJtrue(tree); break; + + default: + // All other gtOper node kinds, leave 'assertionIndex' = NO_ASSERTION_INDEX + break; } // For global assertion prop we must store the assertion number in the tree node @@ -3771,6 +3779,10 @@ EXPSET_TP Compiler::optImpliedByConstAssertion(AssertionDsc* constAssertion) usable = ((impAssertion->assertionKind == OAK_EQUAL) && (impAssertion->op2.u1.iconVal == iconVal)) || ((impAssertion->assertionKind == OAK_NOT_EQUAL) && (impAssertion->op2.u1.iconVal != iconVal)); break; + + default: + // leave 'usable' = false; + break; } if (usable) @@ -3932,6 +3944,10 @@ EXPSET_TP Compiler::optImpliedByCopyAssertion(AssertionDsc* copyAssertion, Asser (depAssertLclNum == impAssertion->op1.lcl.lclNum && depAssertSsaNum == impAssertion->op1.lcl.ssaNum)); } break; + + default: + // leave 'usable' = false; + break; } if (usable) diff --git a/src/jit/codegenxarch.cpp b/src/jit/codegenxarch.cpp index 63efcf0..98a269b 100644 --- a/src/jit/codegenxarch.cpp +++ b/src/jit/codegenxarch.cpp @@ -4220,6 +4220,9 @@ void CodeGen::genCodeForShift(GenTreePtr operand, GenTreePtr shiftBy, case INS_shr: ins = INS_shr_1; break; + default: + // leave 'ins' unchanged + break; } getEmitter()->emitIns_C(ins, attr, operand->gtClsVar.gtClsVarHnd, 0); } @@ -4236,6 +4239,9 @@ void CodeGen::genCodeForShift(GenTreePtr operand, GenTreePtr shiftBy, case INS_shr: ins = INS_shr_N; break; + default: + // leave 'ins' unchanged + break; } if (isClsVarAddr) { diff --git a/src/jit/compiler.h b/src/jit/compiler.h index 3aef4e4..db93683 100644 --- a/src/jit/compiler.h +++ b/src/jit/compiler.h @@ -5517,6 +5517,10 @@ public: case O2K_SUBRANGE: return ((op2.u2.loBound == that->op2.u2.loBound) && (op2.u2.hiBound == that->op2.u2.hiBound)); + + case O2K_INVALID: + // we will return false + break; } return false; } diff --git a/src/jit/gentree.cpp b/src/jit/gentree.cpp index 76c9f50..d24eb23 100644 --- a/src/jit/gentree.cpp +++ b/src/jit/gentree.cpp @@ -6267,6 +6267,10 @@ bool Compiler::gtCompareTree(GenTree * op1, return true; } break; + + default: + // we return false for these unhandled 'oper' kinds + break; } } return false; diff --git a/src/jit/importer.cpp b/src/jit/importer.cpp index f1b161b..682e9a5 100644 --- a/src/jit/importer.cpp +++ b/src/jit/importer.cpp @@ -10306,6 +10306,9 @@ _CONV: case CEE_CONV_OVF_U_UN: case CEE_CONV_U: isNative = true; + default: + // leave 'isNative' = false; + break; } if (isNative) { diff --git a/src/jit/loopcloning.cpp b/src/jit/loopcloning.cpp index 33b7a3f..a6e5b68 100644 --- a/src/jit/loopcloning.cpp +++ b/src/jit/loopcloning.cpp @@ -175,6 +175,10 @@ bool LC_Condition::Evaluates(bool* pResult) return true; } break; + + default: + // for all other 'oper' kinds, we will return false + break; } return false; } diff --git a/src/jit/lsra.cpp b/src/jit/lsra.cpp index aa3e4ab..76a98f3 100644 --- a/src/jit/lsra.cpp +++ b/src/jit/lsra.cpp @@ -2439,6 +2439,10 @@ LinearScan::getKillSetForNode(GenTree* tree) // rep movs kills RCX, RDI and RSI killMask = RBM_RCX | RBM_RDI | RBM_RSI; break; + case GenTreeBlkOp::BlkOpKindUnroll: + case GenTreeBlkOp::BlkOpKindInvalid: + // for these 'cpBlkNode->gtBlkOpKind' kinds, we leave 'killMask' = RBM_NONE + break; } } break; @@ -2459,6 +2463,10 @@ LinearScan::getKillSetForNode(GenTree* tree) killMask |= RBM_RCX; } break; + case GenTreeBlkOp::BlkOpKindUnroll: + case GenTreeBlkOp::BlkOpKindInvalid: + // for these 'cpBlkNode->gtBlkOpKind' kinds, we leave 'killMask' = RBM_NONE + break; } } break; @@ -2541,6 +2549,10 @@ LinearScan::getKillSetForNode(GenTree* tree) } break; #endif // PROFILING_SUPPORTED && _TARGET_AMD64_ + + default: + // for all other 'tree->OperGet()' kinds, leave 'killMask' = RBM_NONE + break; } return killMask; } @@ -4499,6 +4511,9 @@ LinearScan::tryAllocateFreeReg(Interval *currentInterval, RefPosition *refPositi } break; } + default: + // for all other 'operTreeNodee->OperGet()' kinds, we leave 'score' unchanged + break; } } } @@ -10039,6 +10054,9 @@ LinearScan::verifyFinalAllocation() assert(regRecord != nullptr); dumpLsraAllocationEvent(LSRA_EVENT_KEPT_ALLOCATION, nullptr, regRecord->regNum, currentBlock); break; + + case RefTypeUpperVectorSaveDef: + case RefTypeUpperVectorSaveUse: case RefTypeDef: case RefTypeUse: case RefTypeParamDef: @@ -10151,7 +10169,13 @@ LinearScan::verifyFinalAllocation() // Do nothing; these will be handled by the RefTypeBB. DBEXEC(VERBOSE, printf(" ")); break; + + case RefTypeInvalid: + case RefTypeBound: + // for these 'currentRefPosition->refType' values, No action to take + break; } + if (currentRefPosition->refType != RefTypeBB) { DBEXEC(VERBOSE, dumpRegRecords()); diff --git a/src/jit/optimizer.cpp b/src/jit/optimizer.cpp index b51e772..61b1881 100644 --- a/src/jit/optimizer.cpp +++ b/src/jit/optimizer.cpp @@ -6710,7 +6710,12 @@ void Compiler::optComputeLoopSideEffectsOfBlock(BasicBlock* blk) { heapHavoc = true; } + break; } + + default: + // All other gtOper node kinds, leave 'heapHavoc' unchanged (i.e. false) + break; } } } diff --git a/src/jit/rangecheck.cpp b/src/jit/rangecheck.cpp index 70e4e96..38eab6a 100644 --- a/src/jit/rangecheck.cpp +++ b/src/jit/rangecheck.cpp @@ -368,6 +368,10 @@ bool RangeCheck::IsMonotonicallyIncreasing(GenTreePtr expr, SearchPath* path) case GT_ASG_ADD: return IsBinOpMonotonicallyIncreasing(asg->gtGetOp1(), asg->gtGetOp2(), GT_ADD, path); + + default: + // All other 'asg->OperGet()' kinds, return false + break; } JITDUMP("Unknown local definition type\n"); return false; @@ -654,6 +658,10 @@ void RangeCheck::MergeEdgeAssertions(GenTreePtr tree, EXPSET_TP assertions, Rang case GT_LE: pRange->uLimit = limit; break; + + default: + // All other 'cmpOper' kinds leave lLimit/uLimit unchanged + break; } JITDUMP("The range after edge merging:"); JITDUMP(pRange->ToString(m_pCompiler->getAllocatorDebugOnly())); @@ -791,11 +799,15 @@ Range RangeCheck::ComputeRangeForLocalDef(BasicBlock* block, GenTreePtr stmt, Ge } case GT_ASG_ADD: - // If the operator of the definition is +=, then compute the range of the operands of +. - // Note that gtGetOp1 will return op1 to be the lhs; in the formulation of ssa, we have - // a side table for defs and the lhs of a += is considered to be a use for SSA numbering. + // If the operator of the definition is +=, then compute the range of the operands of +. + // Note that gtGetOp1 will return op1 to be the lhs; in the formulation of ssa, we have + // a side table for defs and the lhs of a += is considered to be a use for SSA numbering. return ComputeRangeForBinOp(loc->block, loc->stmt, asg->gtGetOp1(), asg->gtGetOp2(), GT_ADD, path, monotonic DEBUGARG(indent)); + + default: + // All other 'asg->OperGet()' kinds, return Limit::keUnknown + break; } return Range(Limit(Limit::keUnknown)); } @@ -955,6 +967,10 @@ bool RangeCheck::DoesVarDefOverflow(BasicBlock* block, GenTreePtr stmt, GenTreeP case GT_ASG_ADD: // For GT_ASG_ADD, op2 is use, op1 is also use since we side table for defs in useasg case. return DoesBinOpOverflow(loc->block, loc->stmt, asg->gtGetOp1(), asg->gtGetOp2(), path); + + default: + // All other 'asg->OperGet()' kinds, conservatively return true + break; } return true; } diff --git a/src/jit/rangecheck.h b/src/jit/rangecheck.h index f656e6e..f803884 100644 --- a/src/jit/rangecheck.h +++ b/src/jit/rangecheck.h @@ -190,7 +190,13 @@ struct Limit } cns += i; return true; + + case keUndef: + case keUnknown: + // For these values of 'type', conservatively return false + break; } + return false; } diff --git a/src/jit/valuenum.cpp b/src/jit/valuenum.cpp index 9dd939a..c562540 100644 --- a/src/jit/valuenum.cpp +++ b/src/jit/valuenum.cpp @@ -1953,7 +1953,11 @@ float ValueNumStore::EvalOpIntegral(VNFunc vnf, float v0, float v1, Value { case GT_MOD: return fmod(v0, v1); + default: + // For any other values of 'oper', we will assert and return 0.0f + break; } + assert(!"EvalOpIntegral with pExcSet"); return 0.0f; } @@ -1965,7 +1969,11 @@ double ValueNumStore::EvalOpIntegral(VNFunc vnf, double v0, double v1, V { case GT_MOD: return fmod(v0, v1); + default: + // For any other value of 'oper', we will assert and return 0.0 + break; } + assert(!"EvalOpIntegral with pExcSet"); return 0.0; }