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

Suyog Kamal Sarda suyog.sarda at samsung.com
Wed Oct 29 06:59:08 PDT 2014


Thanks. I Agree on c++11 becoming standard at some point :)

- Suyog

------- Original Message -------
Sender : Daniel Jasper<djasper at google.com>
Date : Oct 29, 2014 22:55 (GMT+09:00)
Title : Re: Re: [Clang-format] space between closing angles for templates





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

Thanks Daniel for the clarification.

Any opinion on change in error string to include mention about c++11 standard?



Not really, I am mostly working on clang-format. Similarly, I don't know what the tradeoffs for making -std=c++11 the default at some point.


Cheers,
Daniel


Regards,
Suyog

------- Original Message -------
Sender : Daniel Jasper<djasper at google.com>
Date : Oct 29, 2014 22:38 (GMT+09:00)
Title : Re: [Clang-format] space between closing angles for templates


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




More information about the cfe-dev mailing list