Author: Timm Baeder Date: 2026-08-09T07:46:51+02:00 New Revision: f579ae62ac8b7c316467f7a9a8159c608824cff8
URL: https://github.com/llvm/llvm-project/commit/f579ae62ac8b7c316467f7a9a8159c608824cff8 DIFF: https://github.com/llvm/llvm-project/commit/f579ae62ac8b7c316467f7a9a8159c608824cff8.diff LOG: [clang][bytecode][NFC] Use a switch in Pointer::toAPValue (#215054) Added: Modified: clang/lib/AST/ByteCode/Pointer.cpp Removed: ################################################################################ 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
