Skip to content

Commit 6a3fd83

Browse files
committed
clang-format: Fix regression introduced in r221609.
Before: void f() { f(a, c *d); } After: void f() { f(a, c * d); } llvm-svn: 222128
1 parent b412e52 commit 6a3fd83

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,8 @@ class AnnotatingParser {
763763
Previous && Previous->isOneOf(tok::star, tok::amp);
764764
Previous = Previous->Previous)
765765
Previous->Type = TT_PointerOrReference;
766-
Contexts.back().IsExpression = Contexts.back().InCtorInitializer;
766+
if (Line.MustBeDeclaration)
767+
Contexts.back().IsExpression = Contexts.back().InCtorInitializer;
767768
} else if (Current.Previous &&
768769
Current.Previous->Type == TT_CtorInitializerColon) {
769770
Contexts.back().IsExpression = true;

clang/unittests/Format/FormatTest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5009,6 +5009,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
50095009
verifyIndependentOfContext("aaa && aaa->f();");
50105010
verifyIndependentOfContext("int x = ~*p;");
50115011
verifyFormat("Constructor() : a(a), area(width * height) {}");
5012+
verifyFormat("void f() { f(a, c * d); }");
50125013

50135014
verifyIndependentOfContext("InvalidRegions[*R] = 0;");
50145015

0 commit comments

Comments
 (0)