Skip to content

Commit a0a2017

Browse files
committed
[CIR] Add crash test cases for const_cast l-value and cleanup null fixups
This commit adds two minimal test cases to clang/test/CIR/crashes/ for known NYI (not yet implemented) features that cause crashes: 1. const-cast-lvalue.cpp - Tests CXXConstCastExpr l-value emission - Triggers assertion at CIRGenExpr.cpp:2764 - Error: 'Use emitCastLValue below, remove me when adding testcase' - Minimal reproducer showing const_cast in struct member functions 2. cleanup-892-null-fixups.cpp - Tests null fixup popping in cleanups - Triggers UNREACHABLE at CIRGenCleanup.cpp:892 - Missing implementation of EHScopeStack::popNullFixups() - Minimal reproducer with destructors and early returns Both test cases were reduced from multi-megabyte preprocessed files (from LLVM self-host build failures) down to <30 lines using creduce. These tests are marked XFAIL and serve as regression tests for when these features are implemented. Test Plan: - Verified both tests trigger their respective crashes with -fclangir - Tests follow existing pattern in clang/test/CIR/crashes/ - Both tests are properly formatted and minimal
1 parent d0cac23 commit a0a2017

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
2+
// XFAIL: *
3+
//
4+
// Test for UNREACHABLE at CIRGenCleanup.cpp:892
5+
// Null fixups popping not yet implemented
6+
//
7+
// This test triggers the error:
8+
// "UNREACHABLE executed at CIRGenCleanup.cpp:892!"
9+
//
10+
// Original failure: cleanup_892 from LLVM build
11+
// Reduced from /tmp/Regex-8cd677.cpp
12+
13+
inline namespace a {
14+
class c {
15+
public:
16+
template <typename b> c(b);
17+
~c();
18+
};
19+
} // namespace a
20+
class d {
21+
c e() const;
22+
};
23+
class aj {
24+
public:
25+
~aj();
26+
} an;
27+
c d::e() const {
28+
aj ao;
29+
return an;
30+
c(0);
31+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
2+
// XFAIL: *
3+
//
4+
// Test for CXXConstCastExpr l-value emission not implemented
5+
// Assertion at CIRGenExpr.cpp:2764
6+
//
7+
// This test triggers the assertion:
8+
// "Use emitCastLValue below, remove me when adding testcase"
9+
//
10+
// Original failure: assertion_emitcastlvalue from LLVM build
11+
// Reduced from /tmp/DeltaTree-af9b43.cpp
12+
13+
int a;
14+
struct b {
15+
using c = int;
16+
static c d() { const_cast<int &>(a); }
17+
};
18+
struct e {
19+
static bool f() { b::d; }
20+
};
21+
struct g {
22+
static bool h() { e::f; }
23+
};
24+
struct j : g {
25+
using i = int;
26+
static i k() { h; }
27+
};
28+
void l() { j::k; }

0 commit comments

Comments
 (0)