Issue 153891
Summary [clang-format] return type can be split on namespace when member template has comment
Labels clang-format
Assignees
Reporter joelhock
    clang-format version 20.1.0 (https://github.com/llvm/llvm-project.git https://github.com/llvm/llvm-project/commit/24a30daaa559829ad079f2ff7f73eb4e18095f88) formatted code like this:
```
// ---
// IndentWidth:     4
// PenaltyReturnTypeOnItsOwnLine: 800

class MyClass {
    template <bool abool, // a comment
              bool anotherbool>
    static inline std::pair<size_t, MyCustomTypeeeeeeeee>
 myfunccccccccccccccccccccccc(const char *buf, const char *&err);
};
```
whereas clang-format version 21.1.0-rc3 (https://github.com/llvm/llvm-project.git https://github.com/llvm/llvm-project/commit/6096d35ea93c75f648a253a00775b4d74915c819) splits the `std::` from the rest of the return type:
```
// ---
// IndentWidth:     4
// PenaltyReturnTypeOnItsOwnLine: 800

class MyClass {
    template <bool abool, // a comment
              bool anotherbool>
 static inline std::
        pair<size_t, MyCustomTypeeeeeeeee> myfunccccccccccccccccccccccc(
            const char *buf, const char *&err);
};
```
i could see this being "as designed," but what's odd is that if the comment in the member template is removed, the formatting 21.1.0-rc3 does changes back to how clang version 20.1.0 did it:
```
// ---
// IndentWidth:     4
// PenaltyReturnTypeOnItsOwnLine: 800

class MyClass {
    template <bool abool, bool anotherbool>
    static inline std::pair<size_t, MyCustomTypeeeeeeeee>
 myfunccccccccccccccccccccccc(const char *buf, const char *&err);
};
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to