diff options
author | Timm Baeder <tbaeder@redhat.com> | 2025-08-26 05:38:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-08-26 05:38:25 +0200 |
commit | fadd87ed9fec13f841670d880d5c8532be480bb8 (patch) | |
tree | 464ff8545840ded8de2df1cb2f799ba995678364 /clang/lib/AST/ByteCode/Pointer.cpp | |
parent | 0a675f553caf7e4babcdcbfa5a5e36f4233c1ad4 (diff) | |
download | llvm-fadd87ed9fec13f841670d880d5c8532be480bb8.zip llvm-fadd87ed9fec13f841670d880d5c8532be480bb8.tar.gz llvm-fadd87ed9fec13f841670d880d5c8532be480bb8.tar.bz2 |
[clang][bytecode] Check that a ltor cast to a complex value is possible (#155152)
When we get to this point, the pointer might _not_ be backed by a
primitive array, so the later code will fail.
Fixes #155144
Diffstat (limited to 'clang/lib/AST/ByteCode/Pointer.cpp')
-rw-r--r-- | clang/lib/AST/ByteCode/Pointer.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/AST/ByteCode/Pointer.cpp b/clang/lib/AST/ByteCode/Pointer.cpp index 38856ad..c3c6722 100644 --- a/clang/lib/AST/ByteCode/Pointer.cpp +++ b/clang/lib/AST/ByteCode/Pointer.cpp @@ -785,8 +785,11 @@ std::optional<APValue> Pointer::toRValue(const Context &Ctx, // Complex types. if (const auto *CT = Ty->getAs<ComplexType>()) { - QualType ElemTy = CT->getElementType(); + // Can happen via C casts. + if (!Ptr.getFieldDesc()->isPrimitiveArray()) + return false; + QualType ElemTy = CT->getElementType(); if (ElemTy->isIntegerType()) { OptPrimType ElemT = Ctx.classify(ElemTy); assert(ElemT); |