Issue 238411
Summary [clang] Crash reproducer source is preprocessed instead of using -frewrite-includes with -std=c++20
Labels clang
Assignees
Reporter gallopruss-sie
    Clang crash reporter normally produces crash source with `-frewrite-includes`, so macros aren't original expanded and `#include` directives are retained (guarded by `__CLANG_REWRITTEN_INCLUDES` / `__CLANG_REWRITTEN_SYSTEM_INCLUDES`). With `-std=c++20`, the reproducer is just preprocessed. This makes reproducers from C++20 code harder to investigate.

### Reproducer

Tested with `clang version 23.0.0git (https://github.com/llvm/llvm-project 0fb13a1897b2f2d4ad140f626deb153b0af39753)` on Linux.

```cpp
// test2.cpp
#include <x86intrin.h>
#pragma clang __debug crash
```

**Without `-std=c++20`** (expected behaviour):

```console
$ clang++ -c test2.cpp
...
$ head /tmp/test2-220b15.cpp
# 1 "<built-in>"
# 1 "test2.cpp"
#if defined(__CLANG_REWRITTEN_INCLUDES) || defined(__CLANG_REWRITTEN_SYSTEM_INCLUDES) /* x86intrin.h expanded by -frewrite-includes */
#include <x86intrin.h>
#else /* x86intrin.h expanded by -frewrite-includes
...
```

**With `-std=c++20`**:

```console
$ clang++ -c test2.cpp -std=c++20
...
$ head /tmp/test2-ddd164.cpp
# 1 "test2.cpp"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 493 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "test2.cpp" 2
# 1 ".../lib/clang/23/include/x86intrin.h" 1 3
# 13 ".../lib/clang/23/include/x86intrin.h" 3
# 1 ".../lib/clang/23/include/ia32intrin.h" 1 3
```

Note that running `-E -frewrite-includes -std=c++20` directly *does* produce rewritten includes, so the rewriter itself works in C++20 mode. The problem appears to be in how the driver chooses the preprocessing mode when generating crash diagnostics.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to