[llvm-bugs] [Bug 43845] New: clang-format error alignment output, need to format twice to make it right
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Oct 30 02:39:31 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=43845
Bug ID: 43845
Summary: clang-format error alignment output, need to format
twice to make it right
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Formatter
Assignee: unassignedclangbugs at nondot.org
Reporter: zehaojin at live.cn
CC: djasper at google.com, klimek at google.com,
llvm-bugs at lists.llvm.org
ubuntu 16.04
clang-format version 8.0.1 (tags/RELEASE_801/final)
clang-format version 10.0.0 (https://github.com/llvm/llvm-project.git
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);
}
}
}
```
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191030/3c8f692b/attachment.html>
More information about the llvm-bugs
mailing list