Skip to content

Commit 4fe4969

Browse files
committed
Propagate errors and report them a bit better in ValueExtractionSynthesizer::Transform.
1 parent 9d670a9 commit 4fe4969

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

lib/Interpreter/ValueExtractionSynthesizer.cpp

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,19 @@ 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+
}
176+
else
177+
**I = SVRInit;
178+
}
179+
else {
180+
// FIXME: Is this leaking anything (lastExpr?)
181+
return Result(D, false);
174182
}
175-
else if (SVRInit)
176-
**I = SVRInit;
177183
}
178184
}
179185
return Result(D, true);
@@ -313,6 +319,8 @@ namespace {
313319
TypeSourceInfo* ETSI
314320
= m_Context->getTrivialTypeSourceInfo(ETy, noLoc);
315321

322+
assert(!Call.isInvalid() && "Invalid Call before building new");
323+
316324
Call = m_Sema->BuildCXXNew(E->getSourceRange(),
317325
/*useGlobal ::*/true,
318326
/*placementLParen*/ noLoc,
@@ -325,6 +333,12 @@ namespace {
325333
/*directInitRange*/E->getSourceRange(),
326334
/*initializer*/E
327335
);
336+
if (Call.isInvalid()) {
337+
m_Sema->Diag(E->getLocStart(), diag::err_undeclared_var_use)
338+
<< "operator new";
339+
return Call.get();
340+
}
341+
328342
// Handle possible cleanups:
329343
Call = m_Sema->ActOnFinishFullExpr(Call.get());
330344
}
@@ -382,11 +396,10 @@ namespace {
382396
}
383397
}
384398

385-
386399
assert(!Call.isInvalid() && "Invalid Call");
387400

388401
// Extend the scope of the temporary cleaner if applicable.
389-
if (Cleanups) {
402+
if (Cleanups && !Call.isInvalid()) {
390403
Cleanups->setSubExpr(Call.get());
391404
Cleanups->setValueKind(Call.get()->getValueKind());
392405
Cleanups->setType(Call.get()->getType());

0 commit comments

Comments
 (0)