<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 - mis-indentation caused by macro/template instantiation"
href="https://bugs.llvm.org/show_bug.cgi?id=43947">43947</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>mis-indentation caused by macro/template instantiation
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>9.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</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>spam@lukas-wirz.de
</td>
</tr>
<tr>
<th>CC</th>
<td>djasper@google.com, klimek@google.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>The problem I'm observing is not limited to clang-format-9 but also exists in 7
and 8 (I'm using the versions that are packaged in Debian/testing).
The .clang-format I'm using contains only "BasedOnStyle: LLVM".
The file that gets misformatted is
<<<<<<<
#define container_output(container)
\
template <typename T>
\
ostream &operator<<(ostream &s, const container<T> &v) {
\
s << "{";
\
for (typename container<T>::const_iterator x(v.begin()); x != v.end();) {
\
s << *x;
\
if (++x != v.end())
\
s << ",";
\
}
\
s << "}";
\
return s;
\
}
container_output(vector)
int myfunc() {
return 0;
}
<span class="quote">>>>>>>></span >
where the macro definition is irrelevant and can be outcommented.
Instantiating the template defined in the macro (correct without semicolon)
causes the following function to be indented as:
<<<<<<<
container_output(vector)
int myfunc() {
return 0;
}
<span class="quote">>>>>>>></span >
which is clearly two indentation-levels too many in the first line.
cheers, Lukas Wirz</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>