@@ -308,14 +308,11 @@ bool ByteCodeExprGen<Emitter>::VisitCastExpr(const CastExpr *CE) {
308
308
// Location for the SubExpr.
309
309
// Since SubExpr is of complex type, visiting it results in a pointer
310
310
// anyway, so we just create a temporary pointer variable.
311
- std::optional< unsigned > SubExprOffset = allocateLocalPrimitive (
311
+ unsigned SubExprOffset = allocateLocalPrimitive (
312
312
SubExpr, PT_Ptr, /* IsConst=*/ true , /* IsExtended=*/ false );
313
- if (!SubExprOffset)
314
- return false ;
315
-
316
313
if (!this ->visit (SubExpr))
317
314
return false ;
318
- if (!this ->emitSetLocal (PT_Ptr, * SubExprOffset, CE))
315
+ if (!this ->emitSetLocal (PT_Ptr, SubExprOffset, CE))
319
316
return false ;
320
317
321
318
PrimType SourceElemT = classifyComplexElementType (SubExpr->getType ());
@@ -324,7 +321,7 @@ bool ByteCodeExprGen<Emitter>::VisitCastExpr(const CastExpr *CE) {
324
321
PrimType DestElemT = classifyPrim (DestElemType);
325
322
// Cast both elements individually.
326
323
for (unsigned I = 0 ; I != 2 ; ++I) {
327
- if (!this ->emitGetLocal (PT_Ptr, * SubExprOffset, CE))
324
+ if (!this ->emitGetLocal (PT_Ptr, SubExprOffset, CE))
328
325
return false ;
329
326
if (!this ->emitArrayElemPop (SourceElemT, I, CE))
330
327
return false ;
@@ -1245,22 +1242,19 @@ bool ByteCodeExprGen<Emitter>::VisitOpaqueValueExpr(const OpaqueValueExpr *E) {
1245
1242
// At this point we either have the evaluated source expression or a pointer
1246
1243
// to an object on the stack. We want to create a local variable that stores
1247
1244
// this value.
1248
- std::optional<unsigned > LocalIndex =
1249
- allocateLocalPrimitive (E, SubExprT, /* IsConst=*/ true );
1250
- if (!LocalIndex)
1251
- return false ;
1252
- if (!this ->emitSetLocal (SubExprT, *LocalIndex, E))
1245
+ unsigned LocalIndex = allocateLocalPrimitive (E, SubExprT, /* IsConst=*/ true );
1246
+ if (!this ->emitSetLocal (SubExprT, LocalIndex, E))
1253
1247
return false ;
1254
1248
1255
1249
// Here the local variable is created but the value is removed from the stack,
1256
1250
// so we put it back if the caller needs it.
1257
1251
if (!DiscardResult) {
1258
- if (!this ->emitGetLocal (SubExprT, * LocalIndex, E))
1252
+ if (!this ->emitGetLocal (SubExprT, LocalIndex, E))
1259
1253
return false ;
1260
1254
}
1261
1255
1262
1256
// This is cleaned up when the local variable is destroyed.
1263
- OpaqueExprs.insert ({E, * LocalIndex});
1257
+ OpaqueExprs.insert ({E, LocalIndex});
1264
1258
1265
1259
return true ;
1266
1260
}
@@ -1654,14 +1648,13 @@ bool ByteCodeExprGen<Emitter>::VisitMaterializeTemporaryExpr(
1654
1648
1655
1649
// For everyhing else, use local variables.
1656
1650
if (SubExprT) {
1657
- if (std::optional<unsigned > LocalIndex = allocateLocalPrimitive (
1658
- SubExpr, *SubExprT, /* IsConst=*/ true , /* IsExtended=*/ true )) {
1659
- if (!this ->visit (SubExpr))
1660
- return false ;
1661
- if (!this ->emitSetLocal (*SubExprT, *LocalIndex, E))
1662
- return false ;
1663
- return this ->emitGetPtrLocal (*LocalIndex, E);
1664
- }
1651
+ unsigned LocalIndex = allocateLocalPrimitive (
1652
+ SubExpr, *SubExprT, /* IsConst=*/ true , /* IsExtended=*/ true );
1653
+ if (!this ->visit (SubExpr))
1654
+ return false ;
1655
+ if (!this ->emitSetLocal (*SubExprT, LocalIndex, E))
1656
+ return false ;
1657
+ return this ->emitGetPtrLocal (LocalIndex, E);
1665
1658
} else {
1666
1659
const Expr *Inner = E->getSubExpr ()->skipRValueSubobjectAdjustments ();
1667
1660
0 commit comments