Author: mydeveloperday Date: 2021-12-18T11:38:29Z New Revision: 936a67f089efd31354cf1f1f3b864b81fb5aad0e
URL: https://github.com/llvm/llvm-project/commit/936a67f089efd31354cf1f1f3b864b81fb5aad0e DIFF: https://github.com/llvm/llvm-project/commit/936a67f089efd31354cf1f1f3b864b81fb5aad0e.diff LOG: [clang-format] Extra spaces surrounding arrow in templated member call in variable decl 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>(); ``` Reviewed By: curdeius Differential Revision: https://reviews.llvm.org/D115903 Added: Modified: clang/lib/Format/TokenAnnotator.cpp clang/unittests/Format/FormatTest.cpp Removed: ################################################################################ diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 6fc3a4d5d18ae..5809e4c40070e 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1679,7 +1679,7 @@ class AnnotatingParser { Current.setType(TT_LambdaArrow); } else if (Current.is(tok::arrow) && AutoFound && Line.MustBeDeclaration && Current.NestingLevel == 0 && - !Current.Previous->is(tok::kw_operator)) { + !Current.Previous->isOneOf(tok::kw_operator, tok::identifier)) { // not auto operator->() -> xxx; Current.setType(TT_TrailingReturnArrow); } else if (Current.is(tok::arrow) && Current.Previous && diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 2b9a72e374144..c2a5fbb5c0d93 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -6780,6 +6780,9 @@ TEST_F(FormatTest, TrailingReturnType) { // Not trailing return types. verifyFormat("void f() { auto a = b->c(); }"); + verifyFormat("auto a = p->foo();"); + verifyFormat("int a = p->foo();"); + verifyFormat("auto lmbd = [] NOEXCEPT -> int { return 0; };"); } TEST_F(FormatTest, DeductionGuides) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits