[clang] [clang][bytecode][NFC] Use UnsignedOrNone for Block::DeclID (PR #154104)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 18 05:10:36 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/154104.diff
3 Files Affected:
- (modified) clang/lib/AST/ByteCode/InterpBlock.h (+5-5)
- (modified) clang/lib/AST/ByteCode/Pointer.h (+1-1)
- (modified) clang/lib/AST/ByteCode/Program.h (+1-1)
``````````diff
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;
``````````
</details>
https://github.com/llvm/llvm-project/pull/154104
More information about the cfe-commits
mailing list