<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 - clang-format error alignment output, need to format twice to make it right"
href="https://bugs.llvm.org/show_bug.cgi?id=43845">43845</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang-format error alignment output, need to format twice to make it right
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</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>zehaojin@live.cn
</td>
</tr>
<tr>
<th>CC</th>
<td>djasper@google.com, klimek@google.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>ubuntu 16.04
clang-format version 8.0.1 (tags/RELEASE_801/final)
clang-format version 10.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
5ba66fa53ba7f5c2c3e384c48a18fa7601dddd45)
clang-format style "{ColumnLimit: 100, AlignConsecutiveAssignments: true,
AlignTrailingComments: true, ReflowComments: true}"
code snippet:
```
void initTask(uint32_t uid, Protocol *req)
{
Context m_ctx;
m_ctx.appId = req->appId;
m_ctx.seqId = req->seqId;
m_ctx.uid = uid;
m_ctx.fromUid = req->fromUid;
m_ctx.fetch = 20; ///no need the client to tell how many to get
m_ctx.reserve = req->optionInfo;
m_ctx.flag = req->flag;
}
```
output:
```
void initTask(uint32_t uid, Protocol* req) {
Context m_ctx;
m_ctx.appId = req->appId;
m_ctx.seqId = req->seqId;
m_ctx.uid = uid;
m_ctx.fromUid = req->fromUid;
m_ctx.fetch = 20; /// no need the client to tell how many to get
m_ctx.reserve = req->optionInfo;
m_ctx.flag = req->flag;
}
```
obviously the assignment operators are not aligned.
I formatted the output code again, then it got the right output as below.
output2
```
void initTask(uint32_t uid, Protocol* req) {
Context m_ctx;
m_ctx.appId = req->appId;
m_ctx.seqId = req->seqId;
m_ctx.uid = uid;
m_ctx.fromUid = req->fromUid;
m_ctx.fetch = 20; /// no need the client to tell how many to get
m_ctx.reserve = req->optionInfo;
m_ctx.flag = req->flag;
}
```
another code case which has the same issue
```
bool func()
{
{
Mutex mutex(&m_mutex);
for(mapIter = uid2ts.begin(); mapIter != uid2ts.end(); ++mapIter)
{
//LOG(Debug, "load uid %u, ts %u", mapIter->first,
mapIter->second);
m_uid2ts[mapIter->first] = mapIter->second;
std::set<uint32_t> &uidset = m_ts2uids[mapIter->second/m_timeGrid];
//about 3 hours;
uidset.insert(mapIter->first);
}
}
}
```</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>