зеркало из https://github.com/microsoft/clang.git
Fix an extremely subtle bug with pointer comparisons: they have to be
unsigned because it's possible (at least in theory) to have have both positive and negative pointers pointing to the same object. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51681 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
1e86b34f15
Коммит
ec2c12646a
|
@ -917,12 +917,12 @@ Value *ScalarExprEmitter::EmitCompare(const BinaryOperator *E,unsigned UICmpOpc,
|
|||
if (LHS->getType()->isFloatingPoint()) {
|
||||
Result = Builder.CreateFCmp((llvm::FCmpInst::Predicate)FCmpOpc,
|
||||
LHS, RHS, "cmp");
|
||||
} else if (LHSTy->isUnsignedIntegerType()) {
|
||||
Result = Builder.CreateICmp((llvm::ICmpInst::Predicate)UICmpOpc,
|
||||
} else if (LHSTy->isSignedIntegerType()) {
|
||||
Result = Builder.CreateICmp((llvm::ICmpInst::Predicate)SICmpOpc,
|
||||
LHS, RHS, "cmp");
|
||||
} else {
|
||||
// Signed integers and pointers.
|
||||
Result = Builder.CreateICmp((llvm::ICmpInst::Predicate)SICmpOpc,
|
||||
// Unsigned integers and pointers.
|
||||
Result = Builder.CreateICmp((llvm::ICmpInst::Predicate)UICmpOpc,
|
||||
LHS, RHS, "cmp");
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
// RUN: clang -emit-llvm %s -o - | grep "icmp ult"
|
||||
|
||||
int a(char* a, char* b) {return a<b;}
|
Загрузка…
Ссылка в новой задаче