diff options
author | Evan Cheng <evan.cheng@apple.com> | 2013-01-10 23:22:53 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2013-01-10 23:22:53 +0000 |
commit | 098d7b76b0105f413df9e748a42a35fdc09733c0 (patch) | |
tree | e658bd3ee3aef04a36ba56895003b619c79eaa0a /llvm/lib/IR | |
parent | 2e64aeda89bf9a901870718a7c3b59effbf7f068 (diff) | |
download | bcm5719-llvm-098d7b76b0105f413df9e748a42a35fdc09733c0.tar.gz bcm5719-llvm-098d7b76b0105f413df9e748a42a35fdc09733c0.zip |
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.
llvm-svn: 172143
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r-- | llvm/lib/IR/Instructions.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp index f2e9813bc63..26398ce8515 100644 --- a/llvm/lib/IR/Instructions.cpp +++ b/llvm/lib/IR/Instructions.cpp @@ -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; |