Ver Fonte

clang-format: Fix more incorrect pointer detection.

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

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222158 91177308-0d34-0410-b5e6-96231b3b80d8
Daniel Jasper há 10 anos atrás
pai
commit
31a3bde4cb
2 ficheiros alterados com 2 adições e 1 exclusões
  1. 1 1
      lib/Format/TokenAnnotator.cpp
  2. 1 0
      unittests/Format/FormatTest.cpp

+ 1 - 1
lib/Format/TokenAnnotator.cpp

@@ -764,7 +764,7 @@ private:
            Previous = Previous->Previous)
            Previous = Previous->Previous)
         Previous->Type = TT_PointerOrReference;
         Previous->Type = TT_PointerOrReference;
       if (Line.MustBeDeclaration)
       if (Line.MustBeDeclaration)
-        Contexts.back().IsExpression = Contexts.back().InCtorInitializer;
+        Contexts.back().IsExpression = Contexts.front().InCtorInitializer;
     } else if (Current.Previous &&
     } else if (Current.Previous &&
                Current.Previous->Type == TT_CtorInitializerColon) {
                Current.Previous->Type == TT_CtorInitializerColon) {
       Contexts.back().IsExpression = true;
       Contexts.back().IsExpression = true;

+ 1 - 0
unittests/Format/FormatTest.cpp

@@ -5009,6 +5009,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
   verifyIndependentOfContext("aaa && aaa->f();");
   verifyIndependentOfContext("aaa && aaa->f();");
   verifyIndependentOfContext("int x = ~*p;");
   verifyIndependentOfContext("int x = ~*p;");
   verifyFormat("Constructor() : a(a), area(width * height) {}");
   verifyFormat("Constructor() : a(a), area(width * height) {}");
+  verifyFormat("Constructor() : a(a), area(a, width * height) {}");
   verifyFormat("void f() { f(a, c * d); }");
   verifyFormat("void f() { f(a, c * d); }");
 
 
   verifyIndependentOfContext("InvalidRegions[*R] = 0;");
   verifyIndependentOfContext("InvalidRegions[*R] = 0;");