From: Daniel Jasper Date: Thu, 22 Mar 2018 14:30:28 +0000 (+0000) Subject: clang-format: Fix SpacesInParentheses with fully qualified names. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3862393ff7675e51e619d037bdf1a7545d7446b1;p=clang 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! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328200 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 681e790f87..7fa2ff7f2e 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -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. diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 400a55827a..fa5506fbfb 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -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 callback;", Spaces);