mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-29 15:04:57 +00:00
Add assertions to CastInst::getCastOpcode to catch attempted conversions
between integers and pointers when the source type is marked signed, since inttoptr and ptrtoint always use zero-extension when the destination is larger than the source. llvm-svn: 72025
This commit is contained in:
parent
3f41e5ca13
commit
20650de700
@ -2220,6 +2220,8 @@ CastInst::getCastOpcode(
|
||||
} else {
|
||||
assert(isa<PointerType>(SrcTy) &&
|
||||
"Casting from a value that is not first-class type");
|
||||
assert(!SrcIsSigned &&
|
||||
"Pointer types cannot be considered signed for conversions!");
|
||||
return PtrToInt; // ptr -> int
|
||||
}
|
||||
} else if (DestTy->isFloatingPoint()) { // Casting to floating pt
|
||||
@ -2259,6 +2261,7 @@ CastInst::getCastOpcode(
|
||||
if (isa<PointerType>(SrcTy)) {
|
||||
return BitCast; // ptr -> ptr
|
||||
} else if (SrcTy->isInteger()) {
|
||||
assert(!SrcIsSigned && "Cannot cast signed integer to pointer!");
|
||||
return IntToPtr; // int -> ptr
|
||||
} else {
|
||||
assert(!"Casting pointer to other than pointer or int");
|
||||
|
Loading…
Reference in New Issue
Block a user