Skip to content

Commit

Permalink
clang-format: Restrict r272537 to function ref qualifiers.
Browse files Browse the repository at this point in the history
Seems this isn't generally desirable.

Before:
  int const * a;

After:
  int const* a;

llvm-svn: 272548
  • Loading branch information
djasper-gh committed Jun 13, 2016
1 parent daae87a commit 1f5d637
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion clang/lib/Format/TokenAnnotator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1994,7 +1994,8 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
return false;
if (Right.is(TT_PointerOrReference))
return (Left.is(tok::r_paren) && Line.MightBeFunctionDecl) ||
(Left.Tok.isLiteral() || Left.is(tok::kw_const) ||
(Left.Tok.isLiteral() || (Left.is(tok::kw_const) && Left.Previous &&
Left.Previous->is(tok::r_paren)) ||
(!Left.isOneOf(TT_PointerOrReference, tok::l_paren) &&
(Style.PointerAlignment != FormatStyle::PAS_Left ||
Line.IsMultiVariableDeclStmt)));
Expand Down
1 change: 1 addition & 0 deletions clang/unittests/Format/FormatTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5755,6 +5755,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaaa, *aaaaaaaaaaaaaaaaaaaaaaaaaaaaa);");

verifyGoogleFormat("int const* a = &b;");
verifyGoogleFormat("**outparam = 1;");
verifyGoogleFormat("*outparam = a * b;");
verifyGoogleFormat("int main(int argc, char** argv) {}");
Expand Down

0 comments on commit 1f5d637

Please sign in to comment.