From c9c4ae5add6d888c381377e4a29587cbaf6239e2 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Mon, 17 Nov 2014 13:55:04 +0000 Subject: [PATCH] clang-format: Fix regression introduced in r221609. Before: void f() { f(a, c *d); } After: void f() { f(a, c * d); } git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222128 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/TokenAnnotator.cpp | 3 ++- unittests/Format/FormatTest.cpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 74fb0f7a72..864f60dee6 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -763,7 +763,8 @@ private: Previous && Previous->isOneOf(tok::star, tok::amp); Previous = Previous->Previous) Previous->Type = TT_PointerOrReference; - Contexts.back().IsExpression = Contexts.back().InCtorInitializer; + if (Line.MustBeDeclaration) + Contexts.back().IsExpression = Contexts.back().InCtorInitializer; } else if (Current.Previous && Current.Previous->Type == TT_CtorInitializerColon) { Contexts.back().IsExpression = true; diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 540dd03b42..1fd95f0486 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -5009,6 +5009,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) { verifyIndependentOfContext("aaa && aaa->f();"); verifyIndependentOfContext("int x = ~*p;"); verifyFormat("Constructor() : a(a), area(width * height) {}"); + verifyFormat("void f() { f(a, c * d); }"); verifyIndependentOfContext("InvalidRegions[*R] = 0;"); -- 2.40.0