]> granicus.if.org Git - clang/commitdiff
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);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221609 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 62ec93f3234e4bdd97b9ed62ce8f1e27f83f4e59..d3d4bb14fdb2d2050f39fd7bc6187c658692537b 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 9d62fbe14faf69fc8d41bd708eae378686598cf7..3485392d4fdf28f9293d089922769472957a5957 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;