summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-11-10 16:57:30 +0000
committerDaniel Jasper <djasper@google.com>2014-11-10 16:57:30 +0000
commit0bd9a19b28b9a5129652a7f0baf3d8f27d8a7186 (patch)
treeb46baf1296ec96a9fd44a29e9143e92f72a37c8e
parent101b364b4621be82582d205705aa867b24e3ddb3 (diff)
downloadbcm5719-llvm-0bd9a19b28b9a5129652a7f0baf3d8f27d8a7186.tar.gz
bcm5719-llvm-0bd9a19b28b9a5129652a7f0baf3d8f27d8a7186.zip
clang-format: Fix pointer formatting.
Before: void f(Bar* a = nullptr, Bar * b); After: void f(Bar* a = nullptr, Bar* b); llvm-svn: 221609
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp1
-rw-r--r--clang/unittests/Format/FormatTest.cpp3
2 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 62ec93f3234..d3d4bb14fdb 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 9d62fbe14fa..3485392d4fd 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<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;
OpenPOWER on IntegriCloud