[clang] [clang][bytecode][NFC] Use switch in `Pointer::isWeak()` (PR #234914)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 23 04:27:07 PDT 2026


https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/234914

And save two lines.

>From ad86e3f3e5f8081af780944e3d4fbf999abf7d9e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Fri, 23 Oct 2026 13:24:37 +0200
Subject: [PATCH] asdf

---
 clang/lib/AST/ByteCode/Pointer.h | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Pointer.h b/clang/lib/AST/ByteCode/Pointer.h
index 6c8ac0066f5977..7b49875e19729f 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 {



More information about the cfe-commits mailing list