https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/154104
None >From e74c626f9646d3f9bb53830aa51bd6b0df9d8e3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbae...@redhat.com> Date: Mon, 18 Aug 2025 14:08:30 +0200 Subject: [PATCH] [clang][bytecode][NFC] Use UnsignedOrNone for Block::DeclID --- clang/lib/AST/ByteCode/InterpBlock.h | 10 +++++----- clang/lib/AST/ByteCode/Pointer.h | 2 +- clang/lib/AST/ByteCode/Program.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/clang/lib/AST/ByteCode/InterpBlock.h b/clang/lib/AST/ByteCode/InterpBlock.h index 7ded1e8649fdf..57766fb1eba74 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); @@ -87,7 +87,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 +177,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