Skip to content

Commit 31d2db2

Browse files
authored
[clang][bytecode][NFC] Use UnsignedOrNone for Block::DeclID (#154104)
1 parent 340fa3e commit 31d2db2

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

clang/lib/AST/ByteCode/InterpBlock.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ class Block final {
5050

5151
public:
5252
/// Creates a new block.
53-
Block(unsigned EvalID, const std::optional<unsigned> &DeclID,
54-
const Descriptor *Desc, bool IsStatic = false, bool IsExtern = false,
55-
bool IsWeak = false, bool IsDummy = false)
53+
Block(unsigned EvalID, UnsignedOrNone DeclID, const Descriptor *Desc,
54+
bool IsStatic = false, bool IsExtern = false, bool IsWeak = false,
55+
bool IsDummy = false)
5656
: Desc(Desc), DeclID(DeclID), EvalID(EvalID), IsStatic(IsStatic) {
5757
assert(Desc);
5858
AccessFlags |= (ExternFlag * IsExtern);
@@ -62,8 +62,7 @@ class Block final {
6262

6363
Block(unsigned EvalID, const Descriptor *Desc, bool IsStatic = false,
6464
bool IsExtern = false, bool IsWeak = false, bool IsDummy = false)
65-
: Desc(Desc), DeclID((unsigned)-1), EvalID(EvalID), IsStatic(IsStatic),
66-
IsDynamic(false) {
65+
: Desc(Desc), EvalID(EvalID), IsStatic(IsStatic), IsDynamic(false) {
6766
assert(Desc);
6867
AccessFlags |= (ExternFlag * IsExtern);
6968
AccessFlags |= (WeakFlag * IsWeak);
@@ -87,7 +86,7 @@ class Block final {
8786
/// Returns the size of the block.
8887
unsigned getSize() const { return Desc->getAllocSize(); }
8988
/// Returns the declaration ID.
90-
std::optional<unsigned> getDeclID() const { return DeclID; }
89+
UnsignedOrNone getDeclID() const { return DeclID; }
9190
/// Returns whether the data of this block has been initialized via
9291
/// invoking the Ctor func.
9392
bool isInitialized() const { return IsInitialized; }
@@ -177,7 +176,7 @@ class Block final {
177176
/// Start of the chain of pointers.
178177
Pointer *Pointers = nullptr;
179178
/// Unique identifier of the declaration.
180-
std::optional<unsigned> DeclID;
179+
UnsignedOrNone DeclID = std::nullopt;
181180
const unsigned EvalID = ~0u;
182181
/// Flag indicating if the block has static storage duration.
183182
bool IsStatic = false;

clang/lib/AST/ByteCode/Pointer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ class Pointer {
593593
}
594594

595595
/// Returns the declaration ID.
596-
std::optional<unsigned> getDeclID() const {
596+
UnsignedOrNone getDeclID() const {
597597
if (isBlockPointer()) {
598598
assert(asBlockPointer().Pointee);
599599
return asBlockPointer().Pointee->getDeclID();

clang/lib/AST/ByteCode/Program.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class Program final {
152152
};
153153

154154
/// Returns the current declaration ID.
155-
std::optional<unsigned> getCurrentDecl() const {
155+
UnsignedOrNone getCurrentDecl() const {
156156
if (CurrentDeclaration == NoDeclaration)
157157
return std::nullopt;
158158
return CurrentDeclaration;

0 commit comments

Comments
 (0)