[llvm-bugs] [Bug 48899] New: Constructor annotations are moved on a newline for classes with uppercase names

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jan 27 06:41:08 PST 2021


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

            Bug ID: 48899
           Summary: Constructor annotations are moved on a newline for
                    classes with uppercase names
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: marius at dreamer-ge.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

There seems to be a difference in the behavior for constructor annotations when
then class name is fully uppercase vs mixed case.

Style:
---
Language:        Cpp
ColumnLimit: 0
...

Example:
class AABB
{
    AABB(const Vector&) noexcept;
};
class Aabb
{
    Aabb(const Vector&) noexcept;
};

Formatted:
class AABB
{
    AABB(const Vector&)
    noexcept; // <- annotation got moved to the next line
};
class Aabb
{
    Aabb(const Vector&) noexcept; //<- annotation remained in place
};

Upon investigating I reached two code locations:

https://github.com/llvm/llvm-project/blob/3e206a5922c18392353ba24e80339301183f679d/clang/lib/Format/UnwrappedLineParser.cpp#L1464

UnwrappedLineParser.cpp#L1464 - seems to treat all uppercase function names as
macros and adds an unwrapped line before processing of annotations

https://github.com/llvm/llvm-project/blob/412ac0e53688364fe1295e864abd53e104eeb554/clang/lib/Format/TokenAnnotator.cpp#L1686

TokenAnnotator.cpp#L1686 - for some reason the logic here is reversed and tags
annotation are only processed when the function name is uppercase

-- 
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/20210127/fdb61c8e/attachment.html>


More information about the llvm-bugs mailing list