Skip to content

Commit 80c87cc

Browse files
committed
Propagate errors and report them a bit better in ValueExtractionSynthesizer::Transform.
1 parent 849b9fd commit 80c87cc

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

lib/Interpreter/ValueExtractionSynthesizer.cpp

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,18 @@ namespace cling {
167167
Expr* SVRInit = SynthesizeSVRInit(lastExpr);
168168
// if we had return stmt update to execute the SVR init, even if the
169169
// wrapper returns void.
170-
if (RS) {
171-
if (ImplicitCastExpr* VoidCast
172-
= dyn_cast<ImplicitCastExpr>(RS->getRetValue()))
173-
VoidCast->setSubExpr(SVRInit);
170+
if (SVRInit) {
171+
if (RS) {
172+
if (ImplicitCastExpr* VoidCast
173+
= dyn_cast<ImplicitCastExpr>(RS->getRetValue()))
174+
VoidCast->setSubExpr(SVRInit);
175+
} else
176+
**I = SVRInit;
177+
} else {
178+
// FIXME: Do this atomically or something so that AST context will not
179+
// contain Expr(s) that are unused for the rest of it's life.
180+
return Result(D, false);
174181
}
175-
else if (SVRInit)
176-
**I = SVRInit;
177182
}
178183
}
179184
return Result(D, true);
@@ -313,6 +318,8 @@ namespace {
313318
TypeSourceInfo* ETSI
314319
= m_Context->getTrivialTypeSourceInfo(ETy, noLoc);
315320

321+
assert(!Call.isInvalid() && "Invalid Call before building new");
322+
316323
Call = m_Sema->BuildCXXNew(E->getSourceRange(),
317324
/*useGlobal ::*/true,
318325
/*placementLParen*/ noLoc,
@@ -325,6 +332,12 @@ namespace {
325332
/*directInitRange*/E->getSourceRange(),
326333
/*initializer*/E
327334
);
335+
if (Call.isInvalid()) {
336+
m_Sema->Diag(E->getLocStart(), diag::err_undeclared_var_use)
337+
<< "operator new";
338+
return Call.get();
339+
}
340+
328341
// Handle possible cleanups:
329342
Call = m_Sema->ActOnFinishFullExpr(Call.get());
330343
}
@@ -382,11 +395,10 @@ namespace {
382395
}
383396
}
384397

385-
386398
assert(!Call.isInvalid() && "Invalid Call");
387399

388400
// Extend the scope of the temporary cleaner if applicable.
389-
if (Cleanups) {
401+
if (Cleanups && !Call.isInvalid()) {
390402
Cleanups->setSubExpr(Call.get());
391403
Cleanups->setValueKind(Call.get()->getValueKind());
392404
Cleanups->setType(Call.get()->getType());

0 commit comments

Comments
 (0)