Skip to content

Commit b3a37c9

Browse files
committed
[CIR][Test] Add crash tests for common STL features hitting NYI code
Add XFAIL tests documenting known crashes when using common C++ standard library features. These tests serve as: 1. Documentation of known limitations 2. Regression tests to detect when features become available 3. Minimal reproducers for future implementation work New crash tests: - exception-ptr.cpp: std::make_exception_ptr crashes (exception handling NYI) - async-future.cpp: std::async/std::future crashes (exception handling NYI) - filesystem-sd-automatic.cpp: std::filesystem range-for crashes (SD_Automatic NYI) - tls-destructor.cpp: thread_local with non-trivial destructor (TLS destructors NYI) All tests are minimal reproducers derived from real-world usage patterns that currently hit unimplemented code paths in ClangIR. These issues are tracked in the cleanup/exception/destructor system design category, requiring architectural decisions before implementation. Test Plan: - All 4 new tests marked XFAIL and fail as expected - Total crash tests: 15 XFAIL tests in clang/test/CIR/crashes/ - No regressions in existing tests
1 parent 0a60a85 commit b3a37c9

File tree

4 files changed

+54
-0
lines changed

4 files changed

+54
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir -fcxx-exceptions -fexceptions
2+
// XFAIL: *
3+
//
4+
// std::async/std::future crashes - exception handling NYI
5+
// Related to exception system design
6+
7+
#include <future>
8+
9+
void test() {
10+
auto f = std::async(std::launch::async, []{ return 42; });
11+
int result = f.get();
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir -fcxx-exceptions -fexceptions
2+
// XFAIL: *
3+
//
4+
// std::make_exception_ptr crashes - exception handling NYI
5+
// Related to exception system design
6+
7+
#include <exception>
8+
#include <stdexcept>
9+
10+
void test() {
11+
std::exception_ptr ep = std::make_exception_ptr(std::runtime_error("test"));
12+
}
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 -std=c++17
2+
// XFAIL: *
3+
//
4+
// std::filesystem with range-for crashes - SD_Automatic not implemented
5+
// Location: CIRGenExpr.cpp:2356
6+
7+
#include <filesystem>
8+
9+
void test() {
10+
namespace fs = std::filesystem;
11+
12+
// This triggers SD_Automatic for the directory_iterator temporary
13+
for (const auto& entry : fs::directory_iterator("/tmp")) {
14+
auto path = entry.path();
15+
}
16+
}
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+
// thread_local with non-trivial destructor not implemented
5+
// Location: CIRGenCXX.cpp:264
6+
// Note: Simple TLS works; only destructors are NYI
7+
8+
#include <string>
9+
10+
thread_local std::string tls_string = "hello";
11+
12+
int test() {
13+
return tls_string.length();
14+
}

0 commit comments

Comments
 (0)