Skip to content

Commit b5264db

Browse files
committed
ConstantExpr
1 parent cc8c941 commit b5264db

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

clang/lib/Sema/SemaChecking.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11374,11 +11374,27 @@ static void AnalyzeComparison(Sema &S, BinaryOperator *E) {
1137411374
LHS->getIntegerConstantExpr(S.Context);
1137511375

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

1138011385
// We only care about expressions where just one side is literal
1138111386
if ((bool)RHSValue ^ (bool)LHSValue) {
11387+
11388+
if (LHSValue) {
11389+
auto *LHSCE = ConstantExpr::Create(S.Context, LHS, APValue(*LHSValue));
11390+
E->setLHS(LHSCE);
11391+
LHS = LHSCE;
11392+
} else if (RHSValue) {
11393+
auto *RHSCE = ConstantExpr::Create(S.Context, RHS, APValue(*RHSValue));
11394+
E->setRHS(RHSCE);
11395+
RHS = RHSCE;
11396+
}
11397+
1138211398
// Is the constant on the RHS or LHS?
1138311399
const bool RhsConstant = (bool)RHSValue;
1138411400
Expr *Const = RhsConstant ? RHS : LHS;

0 commit comments

Comments
 (0)