[llvm-bugs] [Bug 47290] New: FixNamespaceComments doesn't add namespace comments for trivial namespaces

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Aug 23 04:48:04 PDT 2020


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

            Bug ID: 47290
           Summary: FixNamespaceComments doesn't add namespace comments
                    for trivial namespaces
           Product: clang
           Version: 10.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: kuzniar95 at o2.pl
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

Hi,

FixNamespaceComment is documented as the following:
If true, clang-format adds missing namespace end comments and fixes invalid
existing ones.

It always works when I provide invalid namespace comments, but it doesn't work
for some trivial namespaces with no comments.

# file test.cpp
namespace works_when_together {
using foo = int;
typedef int bar;
int baz;
}

namespace doesnt_work1 {
using foo = int;
}

namespace doesnt_work2 {
typedef int bar;
}

namespace doesnt_work3 {
int baz;
}

namespace doesnt_work4 {}

# OUTPUT

$ clang-format -style="{FixNamespaceComments: true}" test.cpp
namespace works_when_together {
using foo = int;
typedef int bar;
int baz;
} // namespace works_when_together

namespace doesnt_work1 {
using foo = int;
}

namespace doesnt_work2 {
typedef int bar;
}

namespace doesnt_work3 {
int baz;
}

namespace doesnt_work4 {}

TESTED on all clang-format major versions since 5 to 10.

-- 
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/20200823/00336c88/attachment.html>


More information about the llvm-bugs mailing list