<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/106405>106405</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
PrintingPolicy does not honor terse output for C files
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
otisonoza
</td>
</tr>
</table>
<pre>
I'm not able to reproduce this on main currently, as when analyzing C files nothing gets matched right now.
I suspect there's another bug somewhere in main.
But on release/19.x it's reproducible.
I created the fix and a small matcher which can be used to reproduce the problem here: https://github.com/llvm/llvm-project/compare/release/19.x...otisonoza:llvm-project:19_x
An example file to analyze looks like this:
````
struct A {
};
int main()
{
struct A a;
return 0;
}
````
Before the fix the output looks as:
````
struct A {
}
````
After the fix:
````
struct A {}
````
But since it's not reproducible on main I was not sure how to proceed.
As far as I can explain, the issue is the following:
When analyzing C++ code, everything is treated as a CXXRecordDecl which honors the printing policy: https://github.com/llvm/llvm-project/blob/d31603eefc2d8becfd1f41327b6a8db3e0e91a27/clang/lib/AST/DeclPrinter.cpp#L1128
When analyzing C code however, these are now RecordDecls which do not bother with the printing policy: https://github.com/llvm/llvm-project/blob/d31603eefc2d8becfd1f41327b6a8db3e0e91a27/clang/lib/AST/DeclPrinter.cpp#L605
This can be problematic when creating reports for example based on clang-tidy findings.
Please consider incorporating this fix into main.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVU2PozgQ_TXOpTQRmBDgwIHuVqSW9tDaHWnntjJ2Ad4xLmSbTmd-_cpAp5ORVrOzp5GiID6q_F49v2fhve4tYs3yB5Y_7cQcBnI1Be3J0jexa0ld6mfGixEsBRCtQQgEDidHapYIYdAeyMIotAU5O4c2mAvjjyA8nAe0IKwwl2_a9vAInTboY6ch3vcYPIwiyAEVON0PASyd9yx5YknzDH72E8oAYUCHjBceRKxEB-3cg6cRz_EN6HX1rW79f5hDROX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