<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 - formatting broken when using inline if inside of templates in class initializer list"
href="https://bugs.llvm.org/show_bug.cgi?id=43988">43988</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>formatting broken when using inline if inside of templates in class initializer list
</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>steffen.seckler@tum.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>clang-format gets confused when dealing with inline ifs in templates within
class initializer lists.
The behavior got worse with clang-format-9, as the indentation of the following
entries in the initializer list are wrongly indented.
==============using braces and clang-format-9==============
template <int someInt> class Base { Base(int i){}; };
template <bool someBool> class Derived : public Base<someBool ? 2 : 3> {
public:
Derived()
: Base<(someBool ? 2 : 3)>{35}, _someMember{3}, _someMember2{2}, //
<-- desired indentation
_someMember3{2} {}
private:
int _someMember;
int _someMember2;
int _someMember3;
};
==============without braces and clang-format-9==============
template <int someInt> class Base { Base(int i){}; };
template <bool someBool> class Derived : public Base<someBool ? 2 : 3> {
public:
Derived()
: Base < someBool
? 2
: 3 > {35},
_someMember{3}, _someMember2{2}, _someMember3{2} {}
// <-- wrong indentation
private:
int _someMember;
int _someMember2;
int _someMember3;
};
==============without braces and clang-format-8==============
template <int someInt> class Base { Base(int i){}; };
template <bool someBool> class Derived : public Base<someBool ? 2 : 3> {
public:
Derived()
: Base < someBool
? 2
: 3 > {35},
_someMember{3}, _someMember2{2}, _someMember3{2} {}
// <-- slightly better indentation, but still wrong.
private:
int _someMember;
int _someMember2;
int _someMember3;
};
============================================================
clang-format-9 version:
9.0.1-+2019110812332108004e858e4ac00-1~exp1~20191108215024.72
clang-format-8 version: 8.0.1-svn369350-1~exp1~20190820121219.79</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>