[cfe-dev] [Clang-format] space between closing angles for templates

Daniel Jasper djasper at google.com
Wed Oct 29 06:38:02 PDT 2014


This is controlled by the style flag "Standard" (
http://clang.llvm.org/docs/ClangFormatStyleOptions.html), which is set to
Cpp11 for LLVM style. This is intended as LLVM/Clang code is compiled for
C++11 and we want to format it accordingly. If you need a different
compatibility mode, you can set the flag to a different value as described
on the mentioned page. Certainly, there is no need to change the
implementation ;-).


On Wed, Oct 29, 2014 at 4:39 AM, Suyog Kamal Sarda <suyog.sarda at samsung.com>
wrote:

> Hi Daniel,
>
> Had few questions related to space between closing angles for templates.
>
> Test code : vector<vector<int> > matrix(RR); (there is a space between the
> two closing angles).
>
> When I run clang-format on this, it uses LLVM style by default and
> eliminates space between the two angles.
> After formatting : vector<vector<int>> matrix(RR);
>
> When I try to compile the code, I get the error
> "a space is required between consecutive right angle brackets".
>
> When I compile the formatted code with -std=c++11 option, it compiles
> without error.
> The new standard accepts closing angles without spaces while older needs
> space between the two.
>
> With other styles - Google, Chromium, Mozilla, Webkit - clang-format
> doesn't remove the space between
> the angles. Google and Chromium style accepts both the format, Webkit and
> Mozilla inserts space if not present.
>
> Does LLVM style by default follow c++11 standard?
> ( I saw both '> >' and '>>' in LLVM code. )
>
> Should the default style (which is LLVM) remove the space or should it
> accept both cases?
>
> Shouldn't the error string "a space is required between consecutive right
> angle brackets" also
> include mention about c++11 standard? Something like 'allowed in c++11
> onwards' to make things
> more clear?
>
> Because running clang-format with default style on code with space
> separate angles
> and then compiling without -std=c++11 option throws error which is
> somewhat confusing.
>
> I tried changing the code the in TokenAnnotator.cpp file in function
> 'calculateFormattingInformation'
> where I keep track of number of TemplateCloser, and if the number > 1 then
> set the SpaceRequiredBefore
> to 1. However this was breaking several test cases, mostly related to
> specific styles.
>
> Regards,
> Suyog
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141029/b880b3c6/attachment.html>


More information about the cfe-dev mailing list