Skip to content

Commit 0a60a85

Browse files
committed
[CIR] Add crash test cases for CXXConstCastExpr l-value and SD_Automatic reference temporaries
This commit adds two minimal test cases to clang/test/CIR/crashes/ for known NYI (not yet implemented) features that cause crashes during a ClangIR-enabled LLVM self-build: 1. const-cast-expr-lvalue.cpp - Tests CXXConstCastExpr l-value emission - Triggers assertion at CIRGenExpr.cpp:2720 - Error: 'Use emitCastLValue below, remove me when adding testcase' - Minimal reproducer: const_cast used as l-value in assignment 2. ref-temp-automatic.cpp - Tests SD_Automatic storage duration for reference temporaries - Triggers UNREACHABLE at CIRGenExpr.cpp:2356 - Error: 'SD_Automatic not implemented' - Minimal reproducer: auto&& binding to temporary return value Both test cases were identified from a ninja build of clang at /tmp/clangbuild compiled with -fclangir. The build revealed multiple unique crash patterns, and these two represent new failure modes not previously documented in the crash test suite. The tests are marked XFAIL and serve as regression tests for when these features are implemented. They follow the existing conventions in clang/test/CIR/crashes/ with proper RUN lines, error location comments, and minimal reproducers. Test Plan: - Verified both tests trigger their respective crashes with -fclangir - Tests pass as expected failures with llvm-lit: build/Release/bin/llvm-lit -v clang/test/CIR/crashes/{const-cast-expr-lvalue,ref-temp-automatic}.cpp Both show: XFAIL (expectedly failed) - Tests follow existing crash test patterns and formatting - Minimal reproducers are concise (<20 lines each)
1 parent 62d85f3 commit 0a60a85

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
2+
// XFAIL: *
3+
//
4+
// CXXConstCastExpr l-value emission not implemented
5+
// Location: CIRGenExpr.cpp:2720
6+
7+
void f() {
8+
const int x = 0;
9+
const_cast<int&>(x) = 1;
10+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
2+
// XFAIL: *
3+
//
4+
// SD_Automatic storage duration for reference temporaries not implemented
5+
// Location: CIRGenExpr.cpp:2356
6+
7+
struct S {
8+
S();
9+
~S();
10+
};
11+
12+
S create();
13+
14+
void f() {
15+
auto&& s = create();
16+
}

0 commit comments

Comments
 (0)