clang-format: Fix SpacesInParentheses with fully qualified names.

When SpacesInParentheses is set to true clang-format does not add a
space before fully qualified names. For example:

  do_something(::globalVar );

Fix by Darby Payne. Thank you!

llvm-svn: 328200
This commit is contained in:
Daniel Jasper 2018-03-22 14:30:28 +00:00
parent 301faac18b
commit d5e9ff4fe2
2 changed files with 3 additions and 1 deletions

View File

@ -2692,7 +2692,8 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
Style.Standard == FormatStyle::LS_Cpp03) ||
!(Left.isOneOf(tok::l_paren, tok::r_paren, tok::l_square,
tok::kw___super, TT_TemplateCloser,
TT_TemplateOpener));
TT_TemplateOpener)) ||
(Left.is(tok ::l_paren) && Style.SpacesInParentheses);
if ((Left.is(TT_TemplateOpener)) != (Right.is(TT_TemplateCloser)))
return Style.SpacesInAngles;
// Space before TT_StructuredBindingLSquare.

View File

@ -8827,6 +8827,7 @@ TEST_F(FormatTest, ConfigurableSpacesInParentheses) {
FormatStyle Spaces = getLLVMStyle();
Spaces.SpacesInParentheses = true;
verifyFormat("do_something( ::globalVar );", Spaces);
verifyFormat("call( x, y, z );", Spaces);
verifyFormat("call();", Spaces);
verifyFormat("std::function<void( int, int )> callback;", Spaces);