CastInst::castIsValid should return true if the dest type is the same as

Value's current type. The casting is trivial even for aggregate type.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172143 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Evan Cheng
2013-01-10 23:22:53 +00:00
parent 0e4776ce61
commit 582e4f278b
2 changed files with 41 additions and 0 deletions
+5
View File
@@ -2624,6 +2624,11 @@ CastInst::castIsValid(Instruction::CastOps op, Value *S, Type *DstTy) {
// Check for type sanity on the arguments
Type *SrcTy = S->getType();
// If this is a cast to the same type then it's trivially true.
if (SrcTy == DstTy)
return true;
if (!SrcTy->isFirstClassType() || !DstTy->isFirstClassType() ||
SrcTy->isAggregateType() || DstTy->isAggregateType())
return false;