[clang] [clang][bytecode][NFC] Use a switch in Pointer::toAPValue (PR #215054)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Aug 8 21:33:03 PDT 2026
llvmorg-github-actions[bot] 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/215054.diff
1 Files Affected:
- (modified) clang/lib/AST/ByteCode/Pointer.cpp (+11-5)
``````````diff
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;
``````````
</details>
https://github.com/llvm/llvm-project/pull/215054
More information about the cfe-commits
mailing list