Skip to content

Commit c0c36aa

Browse files
[clang codegen] fix crash emitting __array_rank (#113186)
Fixed: #113044 the type of `ArrayTypeTraitExpr` can be changed, use i32 directly is incorrect. --------- Co-authored-by: Eli Friedman <[email protected]>
1 parent 1e9a296 commit c0c36aa

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ Bug Fixes in This Version
439439
- Fixed a crash when trying to transform a dependent address space type. Fixes #GH101685.
440440
- Fixed a crash when diagnosing format strings and encountering an empty
441441
delimited escape sequence (e.g., ``"\o{}"``). #GH102218
442+
- Fixed a crash using ``__array_rank`` on 64-bit targets. (#GH113044).
442443
- The warning emitted for an unsupported register variable type now points to
443444
the unsupported type instead of the ``register`` keyword (#GH109776).
444445

clang/lib/CodeGen/CGExprScalar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ class ScalarExprEmitter
722722
}
723723

724724
Value *VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *E) {
725-
return llvm::ConstantInt::get(Builder.getInt32Ty(), E->getValue());
725+
return llvm::ConstantInt::get(ConvertType(E->getType()), E->getValue());
726726
}
727727

728728
Value *VisitExpressionTraitExpr(const ExpressionTraitExpr *E) {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: %clang_cc1 -triple aarch64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
2+
3+
unsigned long array_rank_binary_operator(void) {
4+
// CHECK: ret i64 3
5+
return __array_rank(int[10]) | 2;
6+
}

0 commit comments

Comments
 (0)