From 0bd9a19b28b9a5129652a7f0baf3d8f27d8a7186 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Mon, 10 Nov 2014 16:57:30 +0000 Subject: [PATCH] clang-format: Fix pointer formatting. Before: void f(Bar* a = nullptr, Bar * b); After: void f(Bar* a = nullptr, Bar* b); llvm-svn: 221609 --- clang/lib/Format/TokenAnnotator.cpp | 1 + clang/unittests/Format/FormatTest.cpp | 3 +++ 2 files changed, 4 insertions(+) diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 62ec93f..d3d4bb1 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -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; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 9d62fbe..3485392 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -4984,6 +4984,9 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) { verifyGoogleFormat( "const char* const p = reinterpret_cast(q);"); verifyGoogleFormat("void f(int i = 0, SomeType** temps = NULL);"); + verifyGoogleFormat("void f(Bar* a = nullptr, Bar* b);"); + verifyGoogleFormat("template \n" + "void f(int i = 0, SomeType** temps = NULL);"); FormatStyle Left = getLLVMStyle(); Left.PointerAlignment = FormatStyle::PAS_Left; -- 2.7.4