Skip to content

Commit e8db4a4

Browse files
committed
[Clang] Bail when constant evaluating expression with null type
Normally expressions passed to EvaluateInPlace have a type, but not when a VarDecl initializer is evaluated before the untyped ParenListExpr is replaced with a CXXConstructExpr. This can happen in LLDB. In these cases consteval fails.
1 parent f2e9f88 commit e8db4a4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

clang/lib/AST/ExprConstant.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16719,6 +16719,12 @@ static bool EvaluateInPlace(APValue &Result, EvalInfo &Info, const LValue &This,
1671916719
const Expr *E, bool AllowNonLiteralTypes) {
1672016720
assert(!E->isValueDependent());
1672116721

16722+
// Normally expressions passed to EvaluateInPlace have a type, but not when
16723+
// a VarDecl initializer is evaluated before the untyped ParenListExpr is
16724+
// replaced with a CXXConstructExpr. This can happen in LLDB.
16725+
if (E->getType().isNull())
16726+
return false;
16727+
1672216728
if (!AllowNonLiteralTypes && !CheckLiteralType(Info, E, &This))
1672316729
return false;
1672416730

0 commit comments

Comments
 (0)