<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/155111>155111</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[OpenCL] [Driver] -finclude-default-header causes generating broken preprocessed sources generation on clang crash.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
piotrrak
</td>
</tr>
</table>
<pre>
Due to driver passing it no matter what, there result will be multiple definitions of of every definition in `opencl-c-base.h`
Since this file contains not only declarations, but also definitions and it is not guarded, crash reproduces are bogus eg.:
```
/home/prak/DEV/build-clang-runtimes/lib/clang/22/include/opencl-c-base.h:390:14: error: redefinition of 'memory_scope'
390 | typedef enum memory_scope {
| ^
/home/prak/DEV/build-clang-runtimes/lib/clang/22/include/opencl-c-base.h:390:14: note: previous definition is here
390 | typedef enum memory_scope {
| ^
```
```
In file included from <built-in>:1:
/home/prak/DEV/build-clang-runtimes/lib/clang/22/include/opencl-c-base.h:570:3: error: typedef redefinition with different types ('struct ndrange_t' vs 'struct ndrange_t')
570 | } ndrange_t;
| ^
/home/prak/DEV/build-clang-runtimes/lib/clang/22/include/opencl-c-base.h:570:3: note: previous definition is here
570 | } ndrange_t;
```
and for `__cplusplus` also:
```
In file included from <built-in>:1:
/home/prak/DEV/build-clang-runtimes/lib/clang/22/include/opencl-c-base.h:667:32: error: redefinition of '__remove_address_space'
667 | template <typename _Tp> struct __remove_address_space { using type = _Tp; };
| ^
/home/prak/DEV/build-clang-runtimes/lib/clang/22/include/opencl-c-base.h:667:32: note: previous definition is here
667 | template <typename _Tp> struct __remove_address_space { using type = _Tp; };
```
(Multiple times - since it has definition for each address space)
If this file must exist, it scope should probably be limited to declarations only, or `-finclude-default-header` should be filtered out from cc1 command line in crash reproducers.
Probably doing both would be good.
Right now `-finclude-default-header` in such case is passed twice in reproducer script in addition to preprocessed sources already containing
content of `opencl-c-base.h`
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