Skip to content

Commit 228c535

Browse files
committed
[CIR] Add crash test cases for ClangIR code generation failures
This commit adds six new crash test cases to document known failures in ClangIR code generation. These tests were reduced from failures encountered during a full LLVM build with ClangIR enabled. New test cases: 1. apvalue-constexpr-init.cpp - Tests APValue emission for constexpr array initialization - Triggers assertion at CIRGenExprConst.cpp:2040 - Reduced from MSP430AttributeParser.cpp 2. static-var-dyn-cast.cpp - Tests static variable initialization with global references - Triggers "dyn_cast on a non-existent value" assertion - Occurs in addInitializerToStaticVarDecl 3. cleanup-unreachable.cpp - Tests cleanup block popping with unreachable paths - Triggers UNREACHABLE at CIRGenCleanup.cpp:527 - Related to scope cleanup in function returns 4. static-var-guarded-init.cpp - Tests C++ static variable guarded initialization - Triggers UNREACHABLE at CIRGenDecl.cpp:616 - Guarded init support NYI 5. constexpr-cast.cpp - Tests constexpr cast expressions - Triggers UNREACHABLE at CIRGenExprConst.cpp:1006 - Cast support in constexpr context NYI 6. verification-block-terminator.cpp - Tests CIR verification for conditional blocks - Block with no terminator in if statement - Verification error before CIR passes All tests are marked with XFAIL and include: - RUN lines with proper triple and flags - Comments describing the failure location and error - Attribution to the original source file - Minimized reproducer code via creduce Test Plan: - All tests correctly trigger their respective failures - Tests are properly formatted with clang-format - Tests follow existing crash test conventions
1 parent a0a2017 commit 228c535

File tree

6 files changed

+133
-0
lines changed

6 files changed

+133
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
2+
// XFAIL: *
3+
//
4+
// APValue emission not implemented - assertion failure
5+
// Location: CIRGenExprConst.cpp:2075
6+
//
7+
// Original failure: assertion_apvalue from LLVM build
8+
// Reduced from /tmp/MSP430AttributeParser-875bbc.cpp
9+
10+
template <typename a, int b> struct c {
11+
typedef a d[b];
12+
};
13+
template <typename a, int b> struct h {
14+
c<a, b>::d e;
15+
};
16+
enum f { g };
17+
class i {
18+
struct m {
19+
f j;
20+
int (i::*k)(f);
21+
};
22+
static const h<m, 4> l;
23+
int n(f);
24+
};
25+
constexpr h<i::m, 4> i::l{g, &i::n, {}, {}, {}};
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
2+
// XFAIL: *
3+
//
4+
// Branch-through cleanups NYI
5+
// Location: CIRGenCleanup.cpp:527
6+
//
7+
// Original failure: cleanup_527 from LLVM build
8+
// Reduced from /tmp/MicrosoftDemangleNodes-acf44f.cpp
9+
10+
class c {
11+
public:
12+
~c();
13+
};
14+
struct d {
15+
template <typename> using ac = c;
16+
};
17+
struct e {
18+
typedef d::ac<int> ae;
19+
};
20+
class f {
21+
public:
22+
e::ae ak;
23+
template <typename g> f(g, g);
24+
};
25+
struct h {
26+
f i() const;
27+
};
28+
class j {
29+
public:
30+
~j();
31+
};
32+
f h::i() const {
33+
j a;
34+
f b(0, 0);
35+
return b;
36+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
2+
// XFAIL: *
3+
//
4+
// Constant expression NYI
5+
// Location: CIRGenExprConst.cpp:1006
6+
//
7+
// Original failure: exprconst_1006 from LLVM build
8+
// Reduced from /tmp/HexagonAttributeParser-40f1ed.cpp
9+
10+
class a {
11+
public:
12+
int b(unsigned);
13+
};
14+
class c : a {
15+
struct d {
16+
int (c::*e)(unsigned);
17+
} static const f[];
18+
};
19+
const c::d c::f[]{&a::b};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
2+
// XFAIL: *
3+
//
4+
// dyn_cast on non-existent value - assertion failure
5+
// Location: Casting.h:644
6+
//
7+
// Original failure: assertion_dyncast from LLVM build
8+
// Reduced from /tmp/FormattedStream-a19c5f.cpp
9+
10+
struct a {
11+
template <typename b, typename c> a(b, c);
12+
};
13+
class d {
14+
a e;
15+
16+
public:
17+
d(int) : e(0, 0) {}
18+
};
19+
void f() { static d g(0); }
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
2+
// XFAIL: *
3+
//
4+
// Declaration handling NYI
5+
// Location: CIRGenDecl.cpp:616
6+
//
7+
// Original failure: decl_616 from LLVM build
8+
// Reduced from /tmp/MSFError-102e4d.cpp
9+
10+
class a {
11+
public:
12+
~a();
13+
};
14+
void b() { static a c; }
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
2+
// XFAIL: *
3+
//
4+
// CIR module verification error before passes
5+
// Location: Module verification
6+
//
7+
// Original failure: verification_error from LLVM build
8+
// Reduced from /tmp/Errno-48253a.cpp
9+
10+
inline namespace a {
11+
class b {
12+
public:
13+
~b();
14+
};
15+
} // namespace a
16+
b c() {
17+
b d;
18+
if (0)
19+
return d;
20+
}

0 commit comments

Comments
 (0)