@@ -97,6 +97,8 @@ class PossiblyUnreachableDiag {
97
97
: PD(PD), Loc(Loc), Stmts(Stmts) {}
98
98
};
99
99
100
+ enum class FirstCoroutineStmtKind { co_return , co_await , co_yield };
101
+
100
102
// / Retains information about a function, method, or block that is
101
103
// / currently being parsed.
102
104
class FunctionScopeInfo {
@@ -170,6 +172,7 @@ class FunctionScopeInfo {
170
172
171
173
// / An enumeration representing the kind of the first coroutine statement
172
174
// / in the function. One of co_return, co_await, or co_yield.
175
+ LLVM_PREFERRED_TYPE (FirstCoroutineStmtKind)
173
176
unsigned char FirstCoroutineStmtKind : 2 ;
174
177
175
178
// / Whether we found an immediate-escalating expression.
@@ -502,22 +505,30 @@ class FunctionScopeInfo {
502
505
assert (FirstCoroutineStmtLoc.isInvalid () &&
503
506
" first coroutine statement location already set" );
504
507
FirstCoroutineStmtLoc = Loc;
505
- FirstCoroutineStmtKind = llvm::StringSwitch<unsigned char >(Keyword)
506
- .Case (" co_return" , 0 )
507
- .Case (" co_await" , 1 )
508
- .Case (" co_yield" , 2 );
508
+ FirstCoroutineStmtKind =
509
+ llvm::StringSwitch<unsigned char >(Keyword)
510
+ .Case (" co_return" ,
511
+ llvm::to_underlying (FirstCoroutineStmtKind::co_return ))
512
+ .Case (" co_await" ,
513
+ llvm::to_underlying (FirstCoroutineStmtKind::co_await ))
514
+ .Case (" co_yield" ,
515
+ llvm::to_underlying (FirstCoroutineStmtKind::co_yield ));
509
516
}
510
517
511
518
StringRef getFirstCoroutineStmtKeyword () const {
512
519
assert (FirstCoroutineStmtLoc.isValid ()
513
520
&& " no coroutine statement available" );
514
- switch (FirstCoroutineStmtKind) {
515
- case 0 : return " co_return" ;
516
- case 1 : return " co_await" ;
517
- case 2 : return " co_yield" ;
518
- default :
519
- llvm_unreachable (" FirstCoroutineStmtKind has an invalid value" );
521
+ auto Value =
522
+ static_cast <enum FirstCoroutineStmtKind>(FirstCoroutineStmtKind);
523
+ switch (Value) {
524
+ case FirstCoroutineStmtKind::co_return :
525
+ return " co_return" ;
526
+ case FirstCoroutineStmtKind::co_await :
527
+ return " co_await" ;
528
+ case FirstCoroutineStmtKind::co_yield :
529
+ return " co_yield" ;
520
530
};
531
+ llvm_unreachable (" FirstCoroutineStmtKind has an invalid value" );
521
532
}
522
533
523
534
void setNeedsCoroutineSuspends (bool value = true ) {
@@ -582,25 +593,31 @@ class Capture {
582
593
QualType CaptureType;
583
594
584
595
// / The CaptureKind of this capture.
596
+ LLVM_PREFERRED_TYPE (CaptureKind)
585
597
unsigned Kind : 2 ;
586
598
587
599
// / Whether this is a nested capture (a capture of an enclosing capturing
588
600
// / scope's capture).
601
+ LLVM_PREFERRED_TYPE (bool )
589
602
unsigned Nested : 1 ;
590
603
591
604
// / Whether this is a capture of '*this'.
605
+ LLVM_PREFERRED_TYPE (bool )
592
606
unsigned CapturesThis : 1 ;
593
607
594
608
// / Whether an explicit capture has been odr-used in the body of the
595
609
// / lambda.
610
+ LLVM_PREFERRED_TYPE (bool )
596
611
unsigned ODRUsed : 1 ;
597
612
598
613
// / Whether an explicit capture has been non-odr-used in the body of
599
614
// / the lambda.
615
+ LLVM_PREFERRED_TYPE (bool )
600
616
unsigned NonODRUsed : 1 ;
601
617
602
618
// / Whether the capture is invalid (a capture was required but the entity is
603
619
// / non-capturable).
620
+ LLVM_PREFERRED_TYPE (bool )
604
621
unsigned Invalid : 1 ;
605
622
606
623
public:
0 commit comments