llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-codegen

Author: Congcong Cai (HerrCai0907)

<details>
<summary>Changes</summary>

Fixed: #<!-- -->113044


---
Full diff: https://github.com/llvm/llvm-project/pull/113186.diff


3 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+1) 
- (modified) clang/lib/CodeGen/CGExprScalar.cpp (+1-1) 
- (added) clang/test/CodeGen/builtins-array-rank.cpp (+6) 


``````````diff
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;
+}

``````````

</details>


https://github.com/llvm/llvm-project/pull/113186
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to