r222158 - clang-format: Fix more incorrect pointer detection.

Daniel Jasper djasper at google.com
Mon Nov 17 10:42:22 PST 2014


Author: djasper
Date: Mon Nov 17 12:42:22 2014
New Revision: 222158

URL: http://llvm.org/viewvc/llvm-project?rev=222158&view=rev
Log:
clang-format: Fix more incorrect pointer detection.

Before:
  Constructor() : a(a), b(c, d *e) {}

After:
  Constructor() : a(a), b(c, d * e) {}

Modified:
    cfe/trunk/lib/Format/TokenAnnotator.cpp
    cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=222158&r1=222157&r2=222158&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Nov 17 12:42:22 2014
@@ -764,7 +764,7 @@ private:
            Previous = Previous->Previous)
         Previous->Type = TT_PointerOrReference;
       if (Line.MustBeDeclaration)
-        Contexts.back().IsExpression = Contexts.back().InCtorInitializer;
+        Contexts.back().IsExpression = Contexts.front().InCtorInitializer;
     } else if (Current.Previous &&
                Current.Previous->Type == TT_CtorInitializerColon) {
       Contexts.back().IsExpression = true;

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=222158&r1=222157&r2=222158&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Nov 17 12:42:22 2014
@@ -5009,6 +5009,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStar
   verifyIndependentOfContext("aaa && aaa->f();");
   verifyIndependentOfContext("int x = ~*p;");
   verifyFormat("Constructor() : a(a), area(width * height) {}");
+  verifyFormat("Constructor() : a(a), area(a, width * height) {}");
   verifyFormat("void f() { f(a, c * d); }");
 
   verifyIndependentOfContext("InvalidRegions[*R] = 0;");





More information about the cfe-commits mailing list