Skip to content

Commit e392b11

Browse files
committed
[CIR] Add crash tests from ClangIR build failure analysis
Added minimal crash test cases documenting known NYI features and bugs: 1. bitfield-bool-int-cast.cpp - Location: Casting.h:560 - Error: cast<mlir::Type> assertion failure with boolean bitfield - Tests bool bitfield to int conversion in operator<< 2. const-cast-lvalue.cpp - Location: CIRGenExpr.cpp:2799 - Error: CXXConstCastExpr l-value emission not implemented - Tests const_cast on l-value references 3. non-odr-use-constant.cpp - Location: CIRGenExpr.cpp:1122 - Error: NOUR_Constant (non-ODR-use constant) not implemented - Tests range-based for loop over StringMap/StringSet 4. range-for-temp-automatic.cpp - Location: CIRGenExpr.cpp:2435 - Error: SD_Automatic storage duration for reference temporaries NYI - Tests nested range-based for loops with temporary lifetime extension Tests collected from ninja -C /tmp/clangbuild -k10000 build failure analysis. Test plan: $ llvm-lit -v clang/test/CIR/crashes/*.cpp All tests XFAIL as expected
1 parent b3a37c9 commit e392b11

File tree

4 files changed

+108
-16
lines changed

4 files changed

+108
-16
lines changed
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+
// Bitfield bool to int conversion - type cast assertion failure
5+
// Location: Casting.h:560
6+
7+
struct a {
8+
bool b : 1;
9+
};
10+
class c {
11+
public:
12+
void operator<<(int);
13+
};
14+
void d(c e, a f) { e << f.b; }
Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,25 @@
11
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
22
// XFAIL: *
33
//
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
4+
// CXXConstCastExpr l-value emission not implemented
5+
// Location: CIRGenExpr.cpp:2799
126

137
int a;
148
struct b {
159
using c = int;
1610
static c d() { const_cast<int &>(a); }
1711
};
18-
struct e {
12+
template <typename> struct e {
1913
static bool f() { b::d; }
2014
};
21-
struct g {
22-
static bool h() { e::f; }
23-
};
24-
struct j : g {
25-
using i = int;
26-
static i k() { h; }
15+
template <typename... g, typename h> void i(h) { (e<g>::f || ...); }
16+
class j {
17+
int k;
18+
19+
public:
20+
void l() { i<int>(k); }
2721
};
28-
void l() { j::k; }
22+
void m() {
23+
j n;
24+
n.l();
25+
}
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+
// Non-ODR-use constant expression not implemented
5+
// Location: CIRGenExpr.cpp:1122
6+
7+
namespace llvm {
8+
template<typename ValueTy> class StringMapEntry {};
9+
template<typename ValueTy> class StringMapIterBase {
10+
public:
11+
StringMapEntry<ValueTy>& operator*() const;
12+
StringMapIterBase& operator++();
13+
friend bool operator!=(const StringMapIterBase& LHS, const StringMapIterBase& RHS);
14+
};
15+
template<typename ValueTy> class StringMap {
16+
public:
17+
StringMapIterBase<ValueTy> begin();
18+
StringMapIterBase<ValueTy> end();
19+
};
20+
struct EmptyStringSetTag {};
21+
template<class AllocatorTy = int> class StringSet : public StringMap<EmptyStringSetTag> {};
22+
}
23+
24+
namespace clang {
25+
static llvm::StringSet<> BuiltinClasses;
26+
27+
void EmitBuiltins() {
28+
for (const auto &Entry : BuiltinClasses) {
29+
}
30+
}
31+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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 in range-based for loops
5+
// Location: CIRGenExpr.cpp:2435
6+
7+
template <typename> struct b;
8+
template <typename> struct f;
9+
template <typename c> struct f<c *> {
10+
typedef c d;
11+
};
12+
template <typename e, typename> class j {
13+
public:
14+
f<e>::d operator*();
15+
void operator++();
16+
};
17+
template <typename e, typename g> bool operator!=(j<e, g>, j<e, g>);
18+
template <typename> class k;
19+
template <typename c> struct b<k<c>> {
20+
using h = c *;
21+
};
22+
template <typename i> struct F {
23+
typedef b<i>::h h;
24+
~F();
25+
};
26+
template <typename c, typename i = k<c>> class G : F<i> {
27+
public:
28+
typedef j<typename F<i>::h, int> iterator;
29+
iterator begin();
30+
iterator end();
31+
};
32+
template <typename l> class m {
33+
public:
34+
using n = l;
35+
using o = n *;
36+
using iterator = o;
37+
iterator begin();
38+
iterator end();
39+
};
40+
class p {
41+
public:
42+
G<p *> u();
43+
m<p *> r();
44+
} q;
45+
void s() {
46+
m a = q.r();
47+
for (p *v : a)
48+
for (p *t : v->u())
49+
;
50+
}

0 commit comments

Comments
 (0)