Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion clang/lib/Sema/SemaChecking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11374,11 +11374,27 @@ static void AnalyzeComparison(Sema &S, BinaryOperator *E) {
LHS->getIntegerConstantExpr(S.Context);

// We don't care about expressions whose result is a constant.
if (RHSValue && LHSValue)
if (RHSValue && LHSValue) {
auto *LHSCE = ConstantExpr::Create(S.Context, LHS, APValue(*LHSValue));
auto *RHSCE = ConstantExpr::Create(S.Context, RHS, APValue(*RHSValue));
E->setLHS(LHSCE);
E->setRHS(RHSCE);
return AnalyzeImpConvsInComparison(S, E);
}

// We only care about expressions where just one side is literal
if ((bool)RHSValue ^ (bool)LHSValue) {

if (LHSValue) {
auto *LHSCE = ConstantExpr::Create(S.Context, LHS, APValue(*LHSValue));
E->setLHS(LHSCE);
LHS = LHSCE;
} else if (RHSValue) {
auto *RHSCE = ConstantExpr::Create(S.Context, RHS, APValue(*RHSValue));
E->setRHS(RHSCE);
RHS = RHSCE;
}

// Is the constant on the RHS or LHS?
const bool RhsConstant = (bool)RHSValue;
Expr *Const = RhsConstant ? RHS : LHS;
Expand Down
Loading