Use v.data() instead of &v[0] when SmallVector v might be empty.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72210 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jay Foad
2009-05-21 09:52:38 +00:00
parent 82fe2935bf
commit e3e51c0038
7 changed files with 30 additions and 32 deletions

View File

@@ -260,7 +260,7 @@ static Constant *FoldBitCast(Constant *C, const Type *DestTy,
}
}
return ConstantVector::get(&Result[0], Result.size());
return ConstantVector::get(Result.data(), Result.size());
}
}
@@ -306,10 +306,10 @@ Constant *llvm::ConstantFoldInstruction(Instruction *I, const TargetData *TD) {
if (const CmpInst *CI = dyn_cast<CmpInst>(I))
return ConstantFoldCompareInstOperands(CI->getPredicate(),
&Ops[0], Ops.size(), TD);
Ops.data(), Ops.size(), TD);
else
return ConstantFoldInstOperands(I->getOpcode(), I->getType(),
&Ops[0], Ops.size(), TD);
Ops.data(), Ops.size(), TD);
}
/// ConstantFoldConstantExpression - Attempt to fold the constant expression
@@ -325,10 +325,10 @@ Constant *llvm::ConstantFoldConstantExpression(ConstantExpr *CE,
if (CE->isCompare())
return ConstantFoldCompareInstOperands(CE->getPredicate(),
&Ops[0], Ops.size(), TD);
Ops.data(), Ops.size(), TD);
else
return ConstantFoldInstOperands(CE->getOpcode(), CE->getType(),
&Ops[0], Ops.size(), TD);
Ops.data(), Ops.size(), TD);
}
/// ConstantFoldInstOperands - Attempt to constant fold an instruction with the