<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Extend IndentPPDirectives with a LeaveAsIs option"
href="https://bugs.llvm.org/show_bug.cgi?id=39163">39163</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Extend IndentPPDirectives with a LeaveAsIs option
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Formatter
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>niklas.frykholm@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>djasper@google.com, klimek@google.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Currently IndentPPDirectives can have values None or AfterHash. There has
also been a suggestion of a BeforeHash option.
I suggest adding another option Leave, which would leave preprocessor
directives alone (i.e. not change the indentation at all).
Motivation:
Indenting pre-processor directives can be really tricky with lots of
edge cases. There maybe certain directives you do not want indented,
for example. clang-format already has some detection of include guards
as I understand it, but we also use platform macros around entire
files:
#ifdef OSX
...
#endif
These are not recognized and cause the entire file to be indented.
Further complications arise from interaction between macros and C
code, when you want macros to be indented to the scope of the C code
and the C code to be indented to the scope of the macros, i.e.:
if (x) {
#ifdef OSX
bla();
#endif
}
While it is possible to come up with decent indentation for simple
cases like this, it can get hairy, since the macros don't follow the
C syntax and vice versa. For example, the scopes in C code and the
preprocessor don't have to nest nicely. It may be hard to come up with
good consistent rules for how C/preprocessor interactions should be
handled.
A Leave option would sidestep these thorny issues and leave the
indentation of preprocessor macros to the code author. It should also
be easy to implement.
References:
* <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED FIXED - preprocessor directives indentation"
href="show_bug.cgi?id=17362">https://bugs.llvm.org/show_bug.cgi?id=17362</a>
* <a class="bz_bug_link
bz_status_NEW "
title="NEW - Extend IndentPPDirectives with a BeforeHash option"
href="show_bug.cgi?id=36019">https://bugs.llvm.org/show_bug.cgi?id=36019</a>
* <a class="bz_bug_link
bz_status_NEW "
title="NEW - Add option to IndentPPDirectives to respect indentation of context"
href="show_bug.cgi?id=36020">https://bugs.llvm.org/show_bug.cgi?id=36020</a></pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>