Skip to content

Commit 4e16a75

Browse files
committed
[clang][NFC] Annotate Sema/ScopeInfo.h with preferred_type
This helps debuggers to display values in bit-fields in a more helpful way.
1 parent 76e3759 commit 4e16a75

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

clang/include/clang/Sema/ScopeInfo.h

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ class PossiblyUnreachableDiag {
9797
: PD(PD), Loc(Loc), Stmts(Stmts) {}
9898
};
9999

100+
enum class FirstCoroutineStmtKind { co_return, co_await, co_yield };
101+
100102
/// Retains information about a function, method, or block that is
101103
/// currently being parsed.
102104
class FunctionScopeInfo {
@@ -170,6 +172,7 @@ class FunctionScopeInfo {
170172

171173
/// An enumeration representing the kind of the first coroutine statement
172174
/// in the function. One of co_return, co_await, or co_yield.
175+
LLVM_PREFERRED_TYPE(FirstCoroutineStmtKind)
173176
unsigned char FirstCoroutineStmtKind : 2;
174177

175178
/// Whether we found an immediate-escalating expression.
@@ -502,22 +505,30 @@ class FunctionScopeInfo {
502505
assert(FirstCoroutineStmtLoc.isInvalid() &&
503506
"first coroutine statement location already set");
504507
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));
509516
}
510517

511518
StringRef getFirstCoroutineStmtKeyword() const {
512519
assert(FirstCoroutineStmtLoc.isValid()
513520
&& "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";
520530
};
531+
llvm_unreachable("FirstCoroutineStmtKind has an invalid value");
521532
}
522533

523534
void setNeedsCoroutineSuspends(bool value = true) {
@@ -582,25 +593,31 @@ class Capture {
582593
QualType CaptureType;
583594

584595
/// The CaptureKind of this capture.
596+
LLVM_PREFERRED_TYPE(CaptureKind)
585597
unsigned Kind : 2;
586598

587599
/// Whether this is a nested capture (a capture of an enclosing capturing
588600
/// scope's capture).
601+
LLVM_PREFERRED_TYPE(bool)
589602
unsigned Nested : 1;
590603

591604
/// Whether this is a capture of '*this'.
605+
LLVM_PREFERRED_TYPE(bool)
592606
unsigned CapturesThis : 1;
593607

594608
/// Whether an explicit capture has been odr-used in the body of the
595609
/// lambda.
610+
LLVM_PREFERRED_TYPE(bool)
596611
unsigned ODRUsed : 1;
597612

598613
/// Whether an explicit capture has been non-odr-used in the body of
599614
/// the lambda.
615+
LLVM_PREFERRED_TYPE(bool)
600616
unsigned NonODRUsed : 1;
601617

602618
/// Whether the capture is invalid (a capture was required but the entity is
603619
/// non-capturable).
620+
LLVM_PREFERRED_TYPE(bool)
604621
unsigned Invalid : 1;
605622

606623
public:

0 commit comments

Comments
 (0)