Skip to content

Commit 9bd02e6

Browse files
committed
[Clang][CodeGen] Use EvaluateAsBooleanCondition
1 parent e9954e1 commit 9bd02e6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4823,11 +4823,12 @@ bool CodeGenFunction::isUnderlyingBasePointerConstantNull(const Expr *E) {
48234823
// Workaround for old glibc's __PTR_ALIGN macro
48244824
// If the condition can be constant evaluated, we check the selected arm.
48254825
if (auto *Select = dyn_cast<ConditionalOperator>(UnderlyingBaseExpr)) {
4826-
if (auto *C = dyn_cast_if_present<llvm::Constant>(
4827-
ConstantEmitter(*this).tryEmitAbstract(
4828-
Select->getCond(), Select->getCond()->getType())))
4826+
bool EvalResult;
4827+
if (Select->getCond()->EvaluateAsBooleanCondition(EvalResult,
4828+
getContext())) {
48294829
return isUnderlyingBasePointerConstantNull(
4830-
C->isNullValue() ? Select->getFalseExpr() : Select->getTrueExpr());
4830+
EvalResult ? Select->getTrueExpr() : Select->getFalseExpr());
4831+
}
48314832
}
48324833
return getContext().isSentinelNullExpr(UnderlyingBaseExpr);
48334834
}

0 commit comments

Comments
 (0)