[clang] [clang] use ArrayTypeTraitExpr::getType as value type (PR #113186)
Congcong Cai via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 21 16:55:36 PDT 2024
https://github.com/HerrCai0907 updated https://github.com/llvm/llvm-project/pull/113186
>From 938de3d98db4b8e784cb7ec12b940e686ba1f304 Mon Sep 17 00:00:00 2001
From: Congcong Cai <congcongcai0907 at 163.com>
Date: Mon, 21 Oct 2024 23:49:04 +0800
Subject: [PATCH 1/2] [clang] use ArrayTypeTraitExpr::getType as value type
Fixed: #113044
---
clang/docs/ReleaseNotes.rst | 1 +
clang/lib/CodeGen/CGExprScalar.cpp | 2 +-
clang/test/CodeGen/builtins-array-rank.cpp | 6 ++++++
3 files changed, 8 insertions(+), 1 deletion(-)
create mode 100644 clang/test/CodeGen/builtins-array-rank.cpp
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 35c31452cef411..550c5f1b2c2126 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -374,6 +374,7 @@ Bug Fixes in This Version
- Fixed a crash when trying to transform a dependent address space type. Fixes #GH101685.
- Fixed a crash when diagnosing format strings and encountering an empty
delimited escape sequence (e.g., ``"\o{}"``). #GH102218
+- Fixed a crash when the result of ``__array_rank`` is used as operand for bit operation. (#GH113044).
Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp
index b7f5b932c56b6f..0ea757fc0befdb 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -718,7 +718,7 @@ class ScalarExprEmitter
}
Value *VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *E) {
- return llvm::ConstantInt::get(Builder.getInt32Ty(), E->getValue());
+ return llvm::ConstantInt::get(ConvertType(E->getType()), E->getValue());
}
Value *VisitExpressionTraitExpr(const ExpressionTraitExpr *E) {
diff --git a/clang/test/CodeGen/builtins-array-rank.cpp b/clang/test/CodeGen/builtins-array-rank.cpp
new file mode 100644
index 00000000000000..e6f0a55245aad9
--- /dev/null
+++ b/clang/test/CodeGen/builtins-array-rank.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple aarch64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+
+unsigned long array_rank_binary_operator(void) {
+ // CHECK: ret i64 3
+ return __array_rank(int[10]) | 2;
+}
>From 2190e6962d2b438136b367e937cec771b12a3e5a Mon Sep 17 00:00:00 2001
From: Congcong Cai <congcongcai0907 at 163.com>
Date: Tue, 22 Oct 2024 07:55:28 +0800
Subject: [PATCH 2/2] Update clang/docs/ReleaseNotes.rst
Co-authored-by: Eli Friedman <efriedma at quicinc.com>
---
clang/docs/ReleaseNotes.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ae903d6333b887..72613e5ffaf311 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -439,7 +439,7 @@ Bug Fixes in This Version
- Fixed a crash when trying to transform a dependent address space type. Fixes #GH101685.
- Fixed a crash when diagnosing format strings and encountering an empty
delimited escape sequence (e.g., ``"\o{}"``). #GH102218
-- Fixed a crash when the result of ``__array_rank`` is used as operand for bit operation. (#GH113044).
+- Fixed a crash using ``__array_rank`` on 64-bit targets. (#GH113044).
- The warning emitted for an unsupported register variable type now points to
the unsupported type instead of the ``register`` keyword (#GH109776).
More information about the cfe-commits
mailing list