[clang] [clang][wasm] Resolve assertion errors caused by converting ComplexTy… (PR #70496)

via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 27 12:01:17 PDT 2023


https://github.com/knightXun created https://github.com/llvm/llvm-project/pull/70496

When a function parameter is of the built-in Complex type in Clang, the conversion from ComplexType to RecordType is not possible, resulting in a crash in Clang. RecordType is a helper class for structs, unions, and classes.

https://github.com/llvm/llvm-project/issues/70402

>From 1917fd0fe837b92e7f66c3c08c9d9cf3e69b9a07 Mon Sep 17 00:00:00 2001
From: xuknight <badgangkiller at gmail.com>
Date: Sat, 28 Oct 2023 02:52:43 +0800
Subject: [PATCH] [clang][wasm] Resolve assertion errors caused by converting
 ComplexType to RecordType

When a function parameter is of the built-in Complex type in Clang,
the conversion from ComplexType to RecordType is not possible, resulting in a crash in Clang.
RecordType is a helper class for structs, unions, and classes.
---
 clang/lib/CodeGen/Targets/WebAssembly.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/clang/lib/CodeGen/Targets/WebAssembly.cpp b/clang/lib/CodeGen/Targets/WebAssembly.cpp
index bd332228ce5bbe6..9c222c3e91a1867 100644
--- a/clang/lib/CodeGen/Targets/WebAssembly.cpp
+++ b/clang/lib/CodeGen/Targets/WebAssembly.cpp
@@ -114,6 +114,9 @@ ABIArgInfo WebAssemblyABIInfo::classifyArgumentType(QualType Ty) const {
       return ABIArgInfo::getDirect(CGT.ConvertType(QualType(SeltTy, 0)));
     // For the experimental multivalue ABI, fully expand all other aggregates
     if (Kind == WebAssemblyABIKind::ExperimentalMV) {
+      if (Ty->isComplexType()) {
+        return ABIArgInfo::getDirect();
+      }
       const RecordType *RT = Ty->getAs<RecordType>();
       assert(RT);
       bool HasBitField = false;



More information about the cfe-commits mailing list