This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Extra spaces surrounding arrow in templated member call in variable decl
ClosedPublic

Authored by MyDeveloperDay on Dec 16 2021, 1:42 PM.

Details

Summary

https://github.com/llvm/llvm-project/issues/43196

Fixes #43196

-> is incorrectly interpreted as a TrailingReturnArrow if we've seen an auto

auto p = new A;
auto x = p -> foo<1>();

Diff Detail

Unit TestsFailed

Event Timeline

MyDeveloperDay requested review of this revision.Dec 16 2021, 1:42 PM
MyDeveloperDay created this revision.
curdeius added inline comments.Dec 16 2021, 2:01 PM
clang/lib/Format/TokenAnnotator.cpp
1682

Won't it break lambdas with an identifier (e.g. macro) before the arrow? E.g.:

auto lmbd = [] NOEXCEPT -> int {
  return 0;
};
MyDeveloperDay added inline comments.Dec 16 2021, 3:04 PM
clang/lib/Format/TokenAnnotator.cpp
1682

it doesn't seem so, maybe one of the other rules is catching that

auto lmbd = [] NOEXCEPT -> int { return 0; };

curdeius accepted this revision.Dec 17 2021, 3:18 AM

LGTM.

clang/lib/Format/TokenAnnotator.cpp
1682

Ok, but I'd like to see it as a test case if we don't have something similar already.

This revision is now accepted and ready to land.Dec 17 2021, 3:18 AM
MyDeveloperDay added inline comments.Dec 17 2021, 4:40 AM
clang/lib/Format/TokenAnnotator.cpp
1682

let me add that for completeness before I commit

Add additional test to show lambda's should be ok

owenpan accepted this revision.Dec 17 2021, 10:55 AM
This revision was landed with ongoing or failed builds.Dec 18 2021, 3:45 AM
This revision was automatically updated to reflect the committed changes.