[all-commits] [llvm/llvm-project] 6189dd: [clang-format] [PR45942] [[nodiscard]] causes && t...

MyDeveloperDay via All-commits all-commits at lists.llvm.org
Tue May 19 08:42:25 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 6189dd06ad4889dfbccf185f9d81e72fe9173a8a
      https://github.com/llvm/llvm-project/commit/6189dd06ad4889dfbccf185f9d81e72fe9173a8a
  Author: mydeveloperday <mydeveloperday at gmail.com>
  Date:   2020-05-19 (Tue, 19 May 2020)

  Changed paths:
    M clang/lib/Format/UnwrappedLineParser.cpp
    M clang/unittests/Format/FormatTest.cpp

  Log Message:
  -----------
  [clang-format] [PR45942] [[nodiscard]] causes && to be miss interpreted as BinaryOperators

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

With Chromium style (although that is not important) its just it defines PointerAligmment: Left

The following arguments `S&&` are formatted differently depending on if the class has an attribute between it and the class identifier

```
class S {
  S(S&&) = default;
};

class [[nodiscard]] S {
  S(S &&) = default;
};
```

The prescense of [[nodiscard]] between the `class/struct` and the `{` causes the `{` to be incorrectly seen as a `TT_FunctionLBrace` which in turn transforms all the && to be `TT_BinaryOperators` rather than `TT_PointerOrReference`, as binary operators other spacing rules come into play causing a miss format

This revision resolves this by allowing the parseRecord to consider the [[nodisscard]]

Reviewed By: Abpostelnicu

Subscribers: cfe-commits

Tags: #clang, #clang-format

Differential Revision: https://reviews.llvm.org/D80008




More information about the All-commits mailing list