dpayne created this revision. dpayne added a reviewer: djasper. Herald added subscribers: cfe-commits, klimek.
When SpacesInParentheses is set to true clang-format does not add a space before a global namespace variable. For example this is the output of clang-format for a somewhat contrived exampled. #include <iostream> void print_val( std::ostream &s ) { s << "Hello world" << std::endl; } int main( void ) { print_val(::std::cout ); return 0; } The .clang-format looked like Language: Cpp SpacesInParentheses: true Repository: rC Clang https://reviews.llvm.org/D43957 Files: lib/Format/TokenAnnotator.cpp Index: lib/Format/TokenAnnotator.cpp =================================================================== --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -2631,7 +2631,8 @@ 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.
Index: lib/Format/TokenAnnotator.cpp =================================================================== --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -2631,7 +2631,8 @@ 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.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits