[clang] [clang][bytecode][NFC] Use switch in `Pointer::isWeak()` (PR #234914)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 23 04:27:41 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
And save two lines.
---
Full diff: https://github.com/llvm/llvm-project/pull/234914.diff
1 Files Affected:
- (modified) clang/lib/AST/ByteCode/Pointer.h (+8-10)
``````````diff
diff --git a/clang/lib/AST/ByteCode/Pointer.h b/clang/lib/AST/ByteCode/Pointer.h
index 6c8ac0066f597..7b49875e19729 100644
--- a/clang/lib/AST/ByteCode/Pointer.h
+++ b/clang/lib/AST/ByteCode/Pointer.h
@@ -919,23 +919,21 @@ class Pointer {
}
bool isWeak() const {
- if (isFunctionPointer()) {
+ switch (StorageKind) {
+ case Storage::Fn:
if (!Fn.Func || !Fn.Func->getDecl())
return false;
-
return Fn.Func->getDecl()->isWeak();
- }
-
- if (isOpaquePointer()) {
+ case Storage::Opaque:
if (const VarDecl *BaseDecl = Opaque.getBaseVarDecl())
return BaseDecl->isWeak();
+ break;
+ case Storage::Block:
+ return BS.Pointee->isWeak();
+ default:
return false;
}
- if (!isBlockPointer())
- return false;
-
- assert(isBlockPointer());
- return BS.Pointee->isWeak();
+ llvm_unreachable("Unhandled storage kind");
}
/// Checks if the object is active.
bool isActive() const {
``````````
</details>
https://github.com/llvm/llvm-project/pull/234914
More information about the cfe-commits
mailing list