From: Daniel Jasper Date: Wed, 8 Mar 2017 09:49:12 +0000 (+0000) Subject: clang-format: Get slightly better at understanding */&. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=98183555eb52a2527e1e2b1952d493a5fc25085e;p=clang clang-format: Get slightly better at understanding */&. Before: void f() { MACRO(A * const a); } After: void f() { MACRO(A *const a); } git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@297268 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 1a3b352049..97a22d8e97 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -1302,7 +1302,8 @@ private: return TT_UnaryOperator; const FormatToken *NextToken = Tok.getNextNonComment(); - if (!NextToken || NextToken->isOneOf(tok::arrow, tok::equal) || + if (!NextToken || + NextToken->isOneOf(tok::arrow, tok::equal, tok::kw_const) || (NextToken->is(tok::l_brace) && !NextToken->getNextNonComment())) return TT_PointerOrReference; diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index b785d18d52..506de3b7f7 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -4965,6 +4965,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) { verifyIndependentOfContext("MACRO(int *i);"); verifyIndependentOfContext("MACRO(auto *a);"); verifyIndependentOfContext("MACRO(const A *a);"); + verifyIndependentOfContext("MACRO(A *const a);"); verifyIndependentOfContext("MACRO('0' <= c && c <= '9');"); verifyFormat("void f() { f(float{1}, a * a); }"); // FIXME: Is there a way to make this work?