[llvm-bugs] [Bug 37230] New: ClangFormat - Brace initializer syntax is formatted inconsistently and confusingly when dealing with #ifdef
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Apr 25 01:24:46 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=37230
Bug ID: 37230
Summary: ClangFormat - Brace initializer syntax is formatted
inconsistently and confusingly when dealing with
#ifdef
Product: clang
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Formatter
Assignee: unassignedclangbugs at nondot.org
Reporter: andi at mozilla.com
CC: djasper at google.com, klimek at google.com,
llvm-bugs at lists.llvm.org
Given the following input:
>>template<class T>
>>class NonNull
>>{
>>public:
>> NonNull()
>> : ptr{ nullptr }
>> #ifdef DEBUG
>>, inited(false)
>> #endif
>> {
>> }
>>};
Using the Mozilla style the output is:
>>template<class T>
>>class NonNull
>>{
>>public:
>> NonNull()
>> : ptr
>> {
>> nullptr
>> }
>>#ifdef DEBUG
>> , inited(false)
>>#endif
>> {}
>>};
We can see two issues here:
1. The initialisation of ptr is strange, it's being split on several lines.
Most likely this is because Mozilla cs also uses 'BreakConstructorInitializers'
with FormatStyle::BCIS_BeforeComma
2. inited is not indented properly
Using the Google style the output is:
>>template <class T>
>>class NonNull {
>> public:
>> NonNull() : ptr { nullptr }
>>#ifdef DEBUG
>> , inited(false)
>>#endif
>> {
>> }
>>};
This time the format looks almost accurate except variable inited is not
properly aligned.
Using the LLVM style the output is identical with the Google style.
--
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/20180425/c1d63886/attachment.html>
More information about the llvm-bugs
mailing list