[PATCH] D43957: Fixing issue where a space was not added before a global namespace variable when SpacesInParentheses is set
Darby Payne via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 1 10:18:41 PST 2018
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43957.136567.patch
Type: text/x-patch
Size: 702 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180301/135308b3/attachment.bin>
More information about the cfe-commits
mailing list