Author: Timm Baeder Date: 2025-08-18T15:40:44+02:00 New Revision: 31d2db2a68ae6e810f3e5532b521b913b50cc25e
URL: https://github.com/llvm/llvm-project/commit/31d2db2a68ae6e810f3e5532b521b913b50cc25e DIFF: https://github.com/llvm/llvm-project/commit/31d2db2a68ae6e810f3e5532b521b913b50cc25e.diff LOG: [clang][bytecode][NFC] Use UnsignedOrNone for Block::DeclID (#154104) Added: Modified: clang/lib/AST/ByteCode/InterpBlock.h clang/lib/AST/ByteCode/Pointer.h clang/lib/AST/ByteCode/Program.h Removed: ################################################################################ diff --git a/clang/lib/AST/ByteCode/InterpBlock.h b/clang/lib/AST/ByteCode/InterpBlock.h index 7ded1e8649fdf..8f30a6ece74ee 100644 --- a/clang/lib/AST/ByteCode/InterpBlock.h +++ b/clang/lib/AST/ByteCode/InterpBlock.h @@ -50,9 +50,9 @@ class Block final { public: /// Creates a new block. - Block(unsigned EvalID, const std::optional<unsigned> &DeclID, - const Descriptor *Desc, bool IsStatic = false, bool IsExtern = false, - bool IsWeak = false, bool IsDummy = false) + Block(unsigned EvalID, UnsignedOrNone DeclID, const Descriptor *Desc, + bool IsStatic = false, bool IsExtern = false, bool IsWeak = false, + bool IsDummy = false) : Desc(Desc), DeclID(DeclID), EvalID(EvalID), IsStatic(IsStatic) { assert(Desc); AccessFlags |= (ExternFlag * IsExtern); @@ -62,8 +62,7 @@ class Block final { Block(unsigned EvalID, const Descriptor *Desc, bool IsStatic = false, bool IsExtern = false, bool IsWeak = false, bool IsDummy = false) - : Desc(Desc), DeclID((unsigned)-1), EvalID(EvalID), IsStatic(IsStatic), - IsDynamic(false) { + : Desc(Desc), EvalID(EvalID), IsStatic(IsStatic), IsDynamic(false) { assert(Desc); AccessFlags |= (ExternFlag * IsExtern); AccessFlags |= (WeakFlag * IsWeak); @@ -87,7 +86,7 @@ class Block final { /// Returns the size of the block. unsigned getSize() const { return Desc->getAllocSize(); } /// Returns the declaration ID. - std::optional<unsigned> getDeclID() const { return DeclID; } + UnsignedOrNone getDeclID() const { return DeclID; } /// Returns whether the data of this block has been initialized via /// invoking the Ctor func. bool isInitialized() const { return IsInitialized; } @@ -177,7 +176,7 @@ class Block final { /// Start of the chain of pointers. Pointer *Pointers = nullptr; /// Unique identifier of the declaration. - std::optional<unsigned> DeclID; + UnsignedOrNone DeclID = std::nullopt; const unsigned EvalID = ~0u; /// Flag indicating if the block has static storage duration. bool IsStatic = false; diff --git a/clang/lib/AST/ByteCode/Pointer.h b/clang/lib/AST/ByteCode/Pointer.h index 94c83a0d87bc4..1f6f1cbce5391 100644 --- a/clang/lib/AST/ByteCode/Pointer.h +++ b/clang/lib/AST/ByteCode/Pointer.h @@ -593,7 +593,7 @@ class Pointer { } /// Returns the declaration ID. - std::optional<unsigned> getDeclID() const { + UnsignedOrNone getDeclID() const { if (isBlockPointer()) { assert(asBlockPointer().Pointee); return asBlockPointer().Pointee->getDeclID(); diff --git a/clang/lib/AST/ByteCode/Program.h b/clang/lib/AST/ByteCode/Program.h index 207ceef91da43..b63a70ed8113a 100644 --- a/clang/lib/AST/ByteCode/Program.h +++ b/clang/lib/AST/ByteCode/Program.h @@ -152,7 +152,7 @@ class Program final { }; /// Returns the current declaration ID. - std::optional<unsigned> getCurrentDecl() const { + UnsignedOrNone getCurrentDecl() const { if (CurrentDeclaration == NoDeclaration) return std::nullopt; return CurrentDeclaration; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits