@@ -562,8 +562,10 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
562
562
// We're creating a complex value here, so we need to
563
563
// allocate storage for it.
564
564
if (!Initializing) {
565
- unsigned LocalIndex = allocateTemporary (CE);
566
- if (!this ->emitGetPtrLocal (LocalIndex, CE))
565
+ std::optional<unsigned > LocalIndex = allocateTemporary (CE);
566
+ if (!LocalIndex)
567
+ return false ;
568
+ if (!this ->emitGetPtrLocal (*LocalIndex, CE))
567
569
return false ;
568
570
}
569
571
@@ -679,8 +681,10 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
679
681
assert (CE->getType ()->isVectorType ());
680
682
681
683
if (!Initializing) {
682
- unsigned LocalIndex = allocateTemporary (CE);
683
- if (!this ->emitGetPtrLocal (LocalIndex, CE))
684
+ std::optional<unsigned > LocalIndex = allocateTemporary (CE);
685
+ if (!LocalIndex)
686
+ return false ;
687
+ if (!this ->emitGetPtrLocal (*LocalIndex, CE))
684
688
return false ;
685
689
}
686
690
unsigned ToSize = CE->getType ()->getAs <VectorType>()->getNumElements ();
@@ -759,8 +763,10 @@ bool Compiler<Emitter>::VisitImaginaryLiteral(const ImaginaryLiteral *E) {
759
763
return true ;
760
764
761
765
if (!Initializing) {
762
- unsigned LocalIndex = allocateTemporary (E);
763
- if (!this ->emitGetPtrLocal (LocalIndex, E))
766
+ std::optional<unsigned > LocalIndex = allocateTemporary (E);
767
+ if (!LocalIndex)
768
+ return false ;
769
+ if (!this ->emitGetPtrLocal (*LocalIndex, E))
764
770
return false ;
765
771
}
766
772
@@ -1118,8 +1124,10 @@ template <class Emitter>
1118
1124
bool Compiler<Emitter>::VisitComplexBinOp(const BinaryOperator *E) {
1119
1125
// Prepare storage for result.
1120
1126
if (!Initializing) {
1121
- unsigned LocalIndex = allocateTemporary (E);
1122
- if (!this ->emitGetPtrLocal (LocalIndex, E))
1127
+ std::optional<unsigned > LocalIndex = allocateTemporary (E);
1128
+ if (!LocalIndex)
1129
+ return false ;
1130
+ if (!this ->emitGetPtrLocal (*LocalIndex, E))
1123
1131
return false ;
1124
1132
}
1125
1133
@@ -1175,7 +1183,10 @@ bool Compiler<Emitter>::VisitComplexBinOp(const BinaryOperator *E) {
1175
1183
1176
1184
if (!LHSIsComplex) {
1177
1185
// This is using the RHS type for the fake-complex LHS.
1178
- LHSOffset = allocateTemporary (RHS);
1186
+ std::optional<unsigned > LocalIndex = allocateTemporary (RHS);
1187
+ if (!LocalIndex)
1188
+ return false ;
1189
+ LHSOffset = *LocalIndex;
1179
1190
1180
1191
if (!this ->emitGetPtrLocal (LHSOffset, E))
1181
1192
return false ;
@@ -1347,8 +1358,10 @@ bool Compiler<Emitter>::VisitVectorBinOp(const BinaryOperator *E) {
1347
1358
1348
1359
// Prepare storage for result.
1349
1360
if (!Initializing && !E->isCompoundAssignmentOp ()) {
1350
- unsigned LocalIndex = allocateTemporary (E);
1351
- if (!this ->emitGetPtrLocal (LocalIndex, E))
1361
+ std::optional<unsigned > LocalIndex = allocateTemporary (E);
1362
+ if (!LocalIndex)
1363
+ return false ;
1364
+ if (!this ->emitGetPtrLocal (*LocalIndex, E))
1352
1365
return false ;
1353
1366
}
1354
1367
@@ -4170,14 +4183,16 @@ Compiler<Emitter>::allocateLocal(DeclTy &&Src, QualType Ty,
4170
4183
}
4171
4184
4172
4185
template <class Emitter >
4173
- unsigned Compiler<Emitter>::allocateTemporary(const Expr *E) {
4186
+ std::optional< unsigned > Compiler<Emitter>::allocateTemporary(const Expr *E) {
4174
4187
QualType Ty = E->getType ();
4175
4188
assert (!Ty->isRecordType ());
4176
4189
4177
4190
Descriptor *D = P.createDescriptor (
4178
4191
E, Ty.getTypePtr (), Descriptor::InlineDescMD, Ty.isConstQualified (),
4179
4192
/* IsTemporary=*/ true , /* IsMutable=*/ false , /* Init=*/ nullptr );
4180
- assert (D);
4193
+
4194
+ if (!D)
4195
+ return std::nullopt;
4181
4196
4182
4197
Scope::Local Local = this ->createLocal (D);
4183
4198
VariableScope<Emitter> *S = VarScope;
0 commit comments