================
@@ -3842,10 +3866,146 @@ bool Compiler<Emitter>::VisitPredefinedExpr(const
PredefinedExpr *E) {
template <class Emitter>
bool Compiler<Emitter>::VisitCXXThrowExpr(const CXXThrowExpr *E) {
- if (E->getSubExpr() && !this->discard(E->getSubExpr()))
+ const Expr *SubExpr = E->getSubExpr();
+ if (!Ctx.ExceptionsEnabled) {
+ if (SubExpr && !this->discard(SubExpr))
+ return false;
+ return this->emitInvalid(E);
+ }
+
+ if (!SubExpr)
+ return this->emitReThrow(E);
+
+ QualType ExceptionType = SubExpr->getType();
+ OptPrimType ExceptionT = classify(SubExpr);
+
+ const Descriptor *Desc;
+ if (ExceptionT)
+ Desc = P.createDescriptor(SubExpr, *ExceptionT);
+ else
+ Desc = P.createDescriptor(SubExpr, ExceptionType.getTypePtr(),
+ /*IsConst=*/false);
+
+ if (!this->emitAllocException(Desc, E))
+ return false;
+
+ if (ExceptionT) {
+ if (!this->visit(SubExpr))
+ return false;
+ if (!this->emitInit(*ExceptionT, E))
+ return false;
+ } else {
+ if (!this->visitInitializer(SubExpr))
+ return false;
+ }
+
+ OptPrimType T = classify(E->getSubExpr()->getType());
+ if (!this->emitSaveException(ExceptionType.getTypePtr(), T, E))
return false;
- return this->emitInvalid(E);
+ this->VarScope->destroyLocals();
----------------
tbaederr wrote:
oof
https://github.com/llvm/llvm-project/pull/189410
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits