From a71ab95a8ee42c6ca2068c48f26f27b0a106736d Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Wed, 22 Oct 2014 08:42:58 +0000 Subject: [PATCH] clang-format: Fix incorrect trailing return arrow detection. Before: auto doSomething(Aaaaaa* aaaaaa) -> decltype(aaaaaa -> f()) {} After: auto doSomething(Aaaaaa* aaaaaa) -> decltype(aaaaaa->f()) {} git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220373 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/TokenAnnotator.cpp | 2 +- unittests/Format/FormatTest.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 1949510af7..0f4c2e2d50 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -779,7 +779,7 @@ private: } else if (Current.is(tok::kw_auto)) { AutoFound = true; } else if (Current.is(tok::arrow) && AutoFound && - Line.MustBeDeclaration) { + Line.MustBeDeclaration && Current.NestingLevel == 0) { Current.Type = TT_TrailingReturnArrow; } else if (Current.isOneOf(tok::star, tok::amp, tok::ampamp)) { Current.Type = diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 05e0fc5aa8..e363c76625 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -3526,6 +3526,7 @@ TEST_F(FormatTest, TrailingReturnType) { " -> alias::tensor {}"); verifyFormat("auto SomeFunction(A aaaaaaaaaaaaaaaaaaaaa) const\n" " -> decltype(f(aaaaaaaaaaaaaaaaaaaaa)) {}"); + verifyFormat("auto doSomething(Aaaaaa* aaaaaa) -> decltype(aaaaaa->f()) {}"); // Not trailing return types. verifyFormat("void f() { auto a = b->c(); }"); -- 2.40.0