[PATCH] D140956: [clang-format] Add an option for breaking after C++11 attributes

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 10 14:26:02 PST 2023


owenpan added a comment.

In D140956#4038988 <https://reviews.llvm.org/D140956#4038988>, @krasimir wrote:

> It looks like this regressed the following example:
>
>   % cat test.cc  # formatted with older clang-format
>   aaaaaaaaaaaaaaaaaaaaaaaaa<bbbbbbbbbbb>
>       &cccccccccccccccccccccccccccccccccccccc() {
>     return 1;
>   }
>   % clang-format --version
>   clang-format version 16.0.0 (https://github.com/llvm/llvm-project.git a28f0747c2f3728bd8a6f64f7c8ba80b4e0cda9f)
>   % clang-format -style=google test.cc
>   aaaaaaaaaaaaaaaaaaaaaaaaa<bbbbbbbbbbb> &
>   cccccccccccccccccccccccccccccccccccccc() {
>     return 1;
>   }
>   %
>
> @owenpan, I'm planning to temporarily revert this until you have a chance to investigate.

Was it actually a regression or did this patch also fix a bug? It seems that the continuation indent before the `&` in your example is inconsistent with other similar function declarations.

Before this patch:

  % cat test-all.cc
  aaaaaaaaaaaaaaaaaaaaaaaaa<bbbbbbbbbbb>
      &cccccccccccccccccccccccccccccccccccccc() {
    return 1;
  }
  aaaaaaaaaaaaaaaaaaaaaaaaa_bbbbbbbbbbb_
      &cccccccccccccccccccccccccccccccccccccc() {
    return 1;
  }
  aaaaaaaaaaaaaaaaaaaaaaaaa_bbbbbbbbbbb_
      _cccccccccccccccccccccccccccccccccccccc() {
    return 1;
  }
  aaaaaaaaaaaaaaaaaaaaaaaaa<bbbbbbbbbbb>
      _cccccccccccccccccccccccccccccccccccccc() {
    return 1;
  }
  
  aaaaaaaaaaaaaaaaaaaaaaaaa<bbbbbbbbbbb>
      &cccccccccccccccccccccccccccccccccccccc();
  aaaaaaaaaaaaaaaaaaaaaaaaa_bbbbbbbbbbb_
      &cccccccccccccccccccccccccccccccccccccc();
  aaaaaaaaaaaaaaaaaaaaaaaaa_bbbbbbbbbbb_
      _cccccccccccccccccccccccccccccccccccccc();
  aaaaaaaaaaaaaaaaaaaaaaaaa<bbbbbbbbbbb>
      _cccccccccccccccccccccccccccccccccccccc();
  % clang-format -version
  clang-format version 16.0.0 (https://github.com/llvm/llvm-project f2891086f4b64434ecf471960b6daf6f29fd4328)
  % clang-format -style=google test-all.cc
  aaaaaaaaaaaaaaaaaaaaaaaaa<bbbbbbbbbbb>
      &cccccccccccccccccccccccccccccccccccccc() {
    return 1;
  }
  aaaaaaaaaaaaaaaaaaaaaaaaa_bbbbbbbbbbb_ &
  cccccccccccccccccccccccccccccccccccccc() {
    return 1;
  }
  aaaaaaaaaaaaaaaaaaaaaaaaa_bbbbbbbbbbb_
  _cccccccccccccccccccccccccccccccccccccc() {
    return 1;
  }
  aaaaaaaaaaaaaaaaaaaaaaaaa<bbbbbbbbbbb>
  _cccccccccccccccccccccccccccccccccccccc() {
    return 1;
  }
  
  aaaaaaaaaaaaaaaaaaaaaaaaa<bbbbbbbbbbb>
      &cccccccccccccccccccccccccccccccccccccc();
  aaaaaaaaaaaaaaaaaaaaaaaaa_bbbbbbbbbbb_ &
  cccccccccccccccccccccccccccccccccccccc();
  aaaaaaaaaaaaaaaaaaaaaaaaa_bbbbbbbbbbb_
  _cccccccccccccccccccccccccccccccccccccc();
  aaaaaaaaaaaaaaaaaaaaaaaaa<bbbbbbbbbbb>
  _cccccccccccccccccccccccccccccccccccccc();

After this patch:

  % cf -version
  clang-format version 16.0.0 (https://github.com/llvm/llvm-project a28f0747c2f3728bd8a6f64f7c8ba80b4e0cda9f)
  % cf -style=google test-all.cc
  aaaaaaaaaaaaaaaaaaaaaaaaa<bbbbbbbbbbb> &
  cccccccccccccccccccccccccccccccccccccc() {
    return 1;
  }
  aaaaaaaaaaaaaaaaaaaaaaaaa_bbbbbbbbbbb_ &
  cccccccccccccccccccccccccccccccccccccc() {
    return 1;
  }
  aaaaaaaaaaaaaaaaaaaaaaaaa_bbbbbbbbbbb_
  _cccccccccccccccccccccccccccccccccccccc() {
    return 1;
  }
  aaaaaaaaaaaaaaaaaaaaaaaaa<bbbbbbbbbbb>
  _cccccccccccccccccccccccccccccccccccccc() {
    return 1;
  }
  
  aaaaaaaaaaaaaaaaaaaaaaaaa<bbbbbbbbbbb> &
  cccccccccccccccccccccccccccccccccccccc();
  aaaaaaaaaaaaaaaaaaaaaaaaa_bbbbbbbbbbb_ &
  cccccccccccccccccccccccccccccccccccccc();
  aaaaaaaaaaaaaaaaaaaaaaaaa_bbbbbbbbbbb_
  _cccccccccccccccccccccccccccccccccccccc();
  aaaaaaaaaaaaaaaaaaaaaaaaa<bbbbbbbbbbb>
  _cccccccccccccccccccccccccccccccccccccc();


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140956/new/

https://reviews.llvm.org/D140956



More information about the cfe-commits mailing list