https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/215054
None >From abd05c04da0f1b69782814ca35879d1557971937 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]> Date: Sun, 9 Aug 2026 06:27:29 +0200 Subject: [PATCH] [clang][bytecode][NFC] Use a switch in Pointer::toAPValue --- clang/lib/AST/ByteCode/Pointer.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/clang/lib/AST/ByteCode/Pointer.cpp b/clang/lib/AST/ByteCode/Pointer.cpp index b987b350f9537..4f36d20b352cb 100644 --- a/clang/lib/AST/ByteCode/Pointer.cpp +++ b/clang/lib/AST/ByteCode/Pointer.cpp @@ -176,28 +176,34 @@ APValue Pointer::toAPValue(const ASTContext &ASTCtx) const { if (isZero()) return APValue(APValue::LValueBase(), CharUnits::Zero(), Path, /*IsOnePastEnd=*/false, /*IsNullPtr=*/true); - if (isIntegralPointer()) + + switch (StorageKind) { + case Storage::Int: return APValue(static_cast<const Expr *>(nullptr), CharUnits::fromQuantity(asIntPointer().Value + this->Offset), Path, /*IsOnePastEnd=*/false, /*IsNullPtr=*/false); - if (isFunctionPointer()) { + case Storage::Block: + // See below. + break; + case Storage::Fn: { const FunctionPointer &FP = asFunctionPointer(); if (const FunctionDecl *FD = FP.Func->getDecl()) return APValue(FD, CharUnits::fromQuantity(Offset), {}, /*OnePastTheEnd=*/false, /*IsNull=*/false); return APValue(FP.Func->getExpr(), CharUnits::fromQuantity(Offset), {}, /*OnePastTheEnd=*/false, /*IsNull=*/false); - } - - if (isTypeidPointer()) { + } break; + case Storage::Typeid: { TypeInfoLValue TypeInfo(Typeid.TypePtr); return APValue(APValue::LValueBase::getTypeInfo( TypeInfo, QualType(Typeid.TypeInfoType, 0)), CharUnits::Zero(), {}, /*OnePastTheEnd=*/false, /*IsNull=*/false); + } break; } + assert(isBlockPointer()); // Build the lvalue base from the block. const Descriptor *Desc = getDeclDesc(); APValue::LValueBase Base; _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
