Add diagnostic for unsigned integer comparisions

llvm-svn: 237800
This commit is contained in:
Tobias Grosser 2015-05-20 15:37:11 +00:00
parent 08b8726de3
commit a8512b1784
3 changed files with 44 additions and 1 deletions

View File

@ -70,6 +70,7 @@ enum RejectReasonKind {
rrkAffFunc,
rrkUndefCond,
rrkInvalidCond,
rrkUnsignedCond,
rrkUndefOperand,
rrkNonAffBranch,
rrkNoBasePtr,
@ -355,6 +356,32 @@ public:
//@}
};
//===----------------------------------------------------------------------===//
/// @brief Captures an condition on unsigned values
///
/// We do not yet allow conditions on unsigend values
class ReportUnsignedCond : public ReportAffFunc {
//===--------------------------------------------------------------------===//
// The BasicBlock we found the broken condition in.
BasicBlock *BB;
public:
ReportUnsignedCond(const Instruction *Inst, BasicBlock *BB)
: ReportAffFunc(rrkUnsignedCond, Inst), BB(BB) {}
/// @name LLVM-RTTI interface
//@{
static bool classof(const RejectReason *RR);
//@}
/// @name RejectReason interface
//@{
virtual std::string getMessage() const override;
virtual std::string getEndUserMessage() const override;
//@}
};
//===----------------------------------------------------------------------===//
/// @brief Captures an undefined operand.
class ReportUndefOperand : public ReportAffFunc {

View File

@ -351,7 +351,7 @@ bool ScopDetection::isValidCFG(BasicBlock &BB,
// TODO: This is not sufficient and just hides bugs. However it does pretty
// well.
if (ICmp->isUnsigned() && !AllowUnsigned)
return false;
return invalid<ReportUnsignedCond>(Context, /*Assert=*/true, Br, &BB);
// Are both operands of the ICmp affine?
if (isa<UndefValue>(ICmp->getOperand(0)) ||

View File

@ -207,6 +207,22 @@ bool ReportInvalidCond::classof(const RejectReason *RR) {
return RR->getKind() == rrkInvalidCond;
}
//===----------------------------------------------------------------------===//
// ReportUnsignedCond.
std::string ReportUnsignedCond::getMessage() const {
return ("Condition in BB '" + BB->getName()).str() +
"' performs a comparision on (not yet supported) unsigned integers.";
}
std::string ReportUnsignedCond::getEndUserMessage() const {
return "Unsupported comparision on unsigned integers encountered";
}
bool ReportUnsignedCond::classof(const RejectReason *RR) {
return RR->getKind() == rrkUnsignedCond;
}
//===----------------------------------------------------------------------===//
// ReportUndefOperand.