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

            Bug ID: 46243
           Summary: Clang-Format misplace '&' character in member function
                    arguments when using [[nodiscard]] attribute on class.
           Product: clang
           Version: 10.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected]

When using the [[no_discard]] attribute between the class / struct keyword and
the type name, the reference '&' will be misplaced in declared member functions
taking types references as parameters.

For example, if I have the PointerAlignment attribute set to Left:

```
struct Toto
{
    Toto(Object& obj);
    void Function(Object& obj1, Object& obj2);
};
```

when "[[nodiscard]]" is added, becomes:

```
struct [[nodiscard]] Toto
{
    Toto(Object & obj);
    void Function(Object & obj1, Object & obj2);
};
```

(note the space between 'Object' and '&').

This bug only happens if 'Object' is not a primitive type (so can be class, a
struct, templated or not, an enum, an enum class, an alias), if the reference
is not constant, if the function is not an operator (can be a constructor, a
member function, a static member function) and if the argument is not put after
another argument which is a primitive type, a primitive type reference or any
constant type reference.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to