]> granicus.if.org Git - clang/commitdiff
clang-format: Fix regression introduced in r221609.
authorDaniel Jasper <djasper@google.com>
Mon, 17 Nov 2014 13:55:04 +0000 (13:55 +0000)
committerDaniel Jasper <djasper@google.com>
Mon, 17 Nov 2014 13:55:04 +0000 (13:55 +0000)
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
unittests/Format/FormatTest.cpp

index 74fb0f7a727484cfbc97d6b636c7e78b9e32625c..864f60dee62e57d98fccd9f1a21b252fc1290947 100644 (file)
@@ -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;
index 540dd03b42eda4f9b725af6faeb00796fde13cd0..1fd95f04869c2f67092ea55e6c0ba7416eea90af 100644 (file)
@@ -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;");