clang-format: Fix pointer formatting.
authorDaniel Jasper <djasper@google.com>
Mon, 10 Nov 2014 16:57:30 +0000 (16:57 +0000)
committerDaniel Jasper <djasper@google.com>
Mon, 10 Nov 2014 16:57:30 +0000 (16:57 +0000)
Before:
  void f(Bar* a = nullptr, Bar * b);
After:
  void f(Bar* a = nullptr, Bar* b);

llvm-svn: 221609

clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp

index 62ec93f..d3d4bb1 100644 (file)
@@ -765,6 +765,7 @@ private:
            Previous && Previous->isOneOf(tok::star, tok::amp);
            Previous = Previous->Previous)
         Previous->Type = TT_PointerOrReference;
+      Contexts.back().IsExpression = false;
     } else if (Current.Previous &&
                Current.Previous->Type == TT_CtorInitializerColon) {
       Contexts.back().IsExpression = true;
index 9d62fbe..3485392 100644 (file)
@@ -4984,6 +4984,9 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
   verifyGoogleFormat(
       "const char* const p = reinterpret_cast<const char* const>(q);");
   verifyGoogleFormat("void f(int i = 0, SomeType** temps = NULL);");
+  verifyGoogleFormat("void f(Bar* a = nullptr, Bar* b);");
+  verifyGoogleFormat("template <typename T>\n"
+                     "void f(int i = 0, SomeType** temps = NULL);");
 
   FormatStyle Left = getLLVMStyle();
   Left.PointerAlignment = FormatStyle::PAS_Left;