[llvm-bugs] [Bug 36766] New: Namespaces with one function declaration get formatted incorrectly

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Mar 16 08:15:42 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=36766

            Bug ID: 36766
           Summary: Namespaces with one function declaration get formatted
                    incorrectly
           Product: clang
           Version: 6.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: artemiev.mikhail at gmail.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

Let's consider this example:

$ cat test.cpp
namespace Foo1 { // contains a single function declaration

void a();

}
namespace Foo2 { // contains multiple function declarations

void a();
void b();

}
namespace Bar { // contains a single function definition

void b() {}

}
namespace Baz { // contains mixed definitions/declarations

void b() {}
void a();

}

clang-format formats incorrectly the first namespace:
$ clang-format --style=llvm ~/main6.cpp
namespace Foo1 { // contains a single function declaration

void a();
}
namespace Foo2 { // contains multiple function declarations

void a();
void b();

} // namespace Foo2
namespace Bar { // contains a single function definition

void b() {}

} // namespace Bar
namespace Baz { // contains mixed definitions/declarations

void b() {}
void a();

} // namespace Baz

clang-format removes a blank line before the closing brace and it doesn't fix
the namespace comment.

-- 
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/20180316/a278d06c/attachment.html>


More information about the llvm-bugs mailing list