Skip to content

Commit 2f15372

Browse files
committed
[NFC] Lazily Construct ErrorExpr/ErrorType When Default Arg Request Fails
Preserve debuggability and save a bit of memory by only constructing these when the request fails instead of every time.
1 parent 340c855 commit 2f15372

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/AST/Decl.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6556,9 +6556,12 @@ Expr *ParamDecl::getTypeCheckedDefaultExpr() const {
65566556
}
65576557

65586558
auto &ctx = getASTContext();
6559-
return evaluateOrDefault(
6560-
ctx.evaluator, DefaultArgumentExprRequest{const_cast<ParamDecl *>(this)},
6561-
new (ctx) ErrorExpr(getSourceRange(), ErrorType::get(ctx)));
6559+
if (Expr *E = evaluateOrDefault(
6560+
ctx.evaluator,
6561+
DefaultArgumentExprRequest{const_cast<ParamDecl *>(this)}, nullptr)) {
6562+
return E;
6563+
}
6564+
return new (ctx) ErrorExpr(getSourceRange(), ErrorType::get(ctx));
65626565
}
65636566

65646567
void ParamDecl::setDefaultExpr(Expr *E, bool isTypeChecked) {

0 commit comments

Comments
 (0)