Skip to content

Commit 693e77b

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 9867024 commit 693e77b

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
@@ -16268,6 +16268,12 @@ static bool EvaluateInPlace(APValue &Result, EvalInfo &Info, const LValue &This,
1626816268
const Expr *E, bool AllowNonLiteralTypes) {
1626916269
assert(!E->isValueDependent());
1627016270

16271+
// Normally expressions passed to EvaluateInPlace have a type, but not when
16272+
// a VarDecl initializer is evaluated before the untyped ParenListExpr is
16273+
// replaced with a CXXConstructExpr. This can happen in LLDB.
16274+
if (E->getType().isNull())
16275+
return false;
16276+
1627116277
if (!AllowNonLiteralTypes && !CheckLiteralType(Info, E, &This))
1627216278
return false;
1627316279

0 commit comments

Comments
 (0)