[libFuzzer] don't crash if the condition in a switch has unusual type (e.g. i72)
[oota-llvm.git] / lib / Transforms / IPO / GlobalOpt.cpp
index cc4a79fa67deb89437d8f92a58fb5a973e19961c..af19e7d3b4e0b92c5c74c12d0265ce72379d2f8e 100644 (file)
@@ -1992,11 +1992,9 @@ isSimpleEnoughValueToCommitHelper(Constant *C,
   // Aggregate values are safe if all their elements are.
   if (isa<ConstantArray>(C) || isa<ConstantStruct>(C) ||
       isa<ConstantVector>(C)) {
-    for (unsigned i = 0, e = C->getNumOperands(); i != e; ++i) {
-      Constant *Op = cast<Constant>(C->getOperand(i));
-      if (!isSimpleEnoughValueToCommit(Op, SimpleConstants, DL))
+    for (Value *Op : C->operands())
+      if (!isSimpleEnoughValueToCommit(cast<Constant>(Op), SimpleConstants, DL))
         return false;
-    }
     return true;
   }
 
@@ -3083,3 +3081,4 @@ bool GlobalOpt::runOnModule(Module &M) {
 
   return Changed;
 }
+