<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/95696>95696</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang generate wrong compile_commands.json that are unusable by clangd
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
MatthieuHernandez
</td>
</tr>
</table>
<pre>
When I run this command:
````
clang++ .\\examples\\example_1.cpp -std=c++23 -o example_1.exe -MJ compile_commands.json
````
It generates the following `compile_commands.json`:
```json
{
"directory": "C:\\Programming\\Git\\cpp-is-magic",
"file": ".\\examples\\example_1.cpp",
"output": "C:\\Users\\matth\\AppData\\Local\\Temp\\example_1-fd8c61.o",
"arguments": [
"C:\\Program Files\\LLVM\\bin\\clang++.exe",
"-xc++",
".\\examples\\example_1.cpp",
"-o",
"C:\\Users\\matth\\AppData\\Local\\Temp\\example_1-fd8c61.o",
"--driver-mode=g++",
"-std=c++23",
"-dumpdir",
"example_1.exe-",
"--target=x86_64-pc-windows-msvc19.35.32217"
]
},
```
and `clangd` under `VS Code` (from clangd extension) return this error:
```
Failed to load compilation database from C:/Programming/Git/cpp-is-magic/compile_commands.json: Expected array.
```
If I add brackets `[]` in my `compile_commands.json` it works perfectly.
How can I correct this problem?
Does this bug come from `clang`, `clangd` or the `VS Code` extension?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VU1v4zYQ_TX0ZSBBoiw5OuiQ2FU3RQIUaLs9BiNyLHNXIgWSip3--oKSEseJt0UvBQyYImbezJuPR3ROtZqoYvkdy3crHP3B2OoRvT8oGr-Q1agl_bVqjHyp_jyQhnuwowZ_UA6E6XvUkmW3LNmx5JYVyfk33YgOdcv4HeN3ELN8y_ItnbAfOnIXX09pLIYBIucly3Zi9uAZRAbOFnQiiB5_CWEH1dHTEt7F35zRP8rg3kNLmix6cuAPBHvTdeaodAusSK5DF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