Using C++'11 in llvm/clang itself

FYI, on llvmdev we are discussion whether it makes sense to adopt C++'11 language features in llvm and clang. This obviously affects the clang community as well. My latest proposal is here:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2013-January/058007.html

If you're interested in this, please chime in on the llvmdev thread.

-Chris

FYI, on llvmdev we are discussion whether it makes sense to adopt C++'11 language features in llvm and clang. This obviously affects the clang community as well. My latest proposal is here:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2013-January/058007.html

If you’re interested in this, please chime in on the llvmdev thread.

-Chris

I am interested but I don’t quite understand how I can chime in on the llvmdev thread without first receiving it in my e-mail client, did I miss something in your link ?

Anyway, using the Apache Wiki 1 I summed up what can be used simultaneously by gcc, MSVC and clang.

I voluntarily only considered the latest versions of the proposals where there were several, as I feared that subtly different semantics between two versions of a compiler might cause more harm than good [tm].

Let’s examine the baseline setup: gcc 4.5, MSVC 10 and clang 3.1.

  • extern template (n1987)
  • lambda v1.1 (n2927)
  • local types as template arguments (n2657)
  • new deduced return type (n2541)
  • static_assert (n1720)
  • built-in type traits (n1836)

If we move the bar a little higher: gcc 4.6, MSVC 11 (not CRT nov’ 12) and clang 3.1, we add some features.

  • atomic (n2427) / requires MSVC 11
  • forward enum (n2764) / requires gcc 4.6, MSVC 11
  • nullptr (n2431) / requires gcc 4.6
  • strongly-typed enums (n2347) / requires MSVC 11
  • range-based for (n2930) / requires gcc 4.6, MSVC 11

I attached the extract I did (isolating just the compilers of interest) in case someone finds it useful.

– Matthieu

c++11.txt (1.57 KB)

Matthieu Monrocq <matthieu.monrocq@gmail.com> writes:

If we move the bar a little higher: gcc 4.6, MSVC 11 (not CRT nov' 12)
and clang 3.1, we add some features.

- atomic (n2427) / requires MSVC 11
- forward enum (n2764) / requires gcc 4.6, MSVC 11
- nullptr (n2431) / requires gcc 4.6
- strongly-typed enums (n2347) / requires MSVC 11
- range-based for (n2930) / requires gcc 4.6, MSVC 11

From your extract it looks like MSVC 11 would also add:

- decltype (but for gcc not v1.1 - what is that?)

And MSVC 11.0v2 (I don't know what that is)
would add:

- variadic templates
- initializer lists
- explicit conversions
- raw string literals
- r-value v3.0 (I don't know what that is)

decltype is useful, particularly with the new function declaration
syntax. variadic templates are tremendously useful anmd really cut down
on code bloat. Things like the CommandLine library could _really_
shrink in size with variadic templates.

                                 -David

Matthieu Monrocq <matthieu.monrocq@gmail.com> writes:

If we move the bar a little higher: gcc 4.6, MSVC 11 (not CRT nov' 12)
and clang 3.1, we add some features.

- atomic (n2427) / requires MSVC 11
- forward enum (n2764) / requires gcc 4.6, MSVC 11
- nullptr (n2431) / requires gcc 4.6
- strongly-typed enums (n2347) / requires MSVC 11
- range-based for (n2930) / requires gcc 4.6, MSVC 11

>From your extract it looks like MSVC 11 would also add:

- decltype (but for gcc not v1.1 - what is that?)

MSVC appears to be using it to refer to N3276, which I've briefly looked over to see how it changes decltype. The changes in N3276 amount to dropping the necessity of having intermediates in the expression as a result of function calls being complete types.

And MSVC 11.0v2 (I don't know what that is)

MSVC released a followup update to MSVC 11 (or 2012) which added more C++11 features; this is generally called the "November CTP".

Hi guys,

Please continue this discussion on llvmdev to keep the discussion in one place.

-Chris

Hi Chris,

As I said, I’d like to, however I never got the llvmdev thread in my e-mail box because I don’t subscribe there, which kinda prevents me from replying to it. Unless there is something I am missing in which I apologize for being dumb.

If someone involed in the llvmdev thread could reply to it and put me in copy, I would then be more than happy to discuss it there. I won’t have much to say though, just wanted to contribute the list of features and their availability to help you all deciding in due knowledge.

– Matthieu.

Matthieu Monrocq wrote:

Hi Chris,

As I said, I'd like to, however I never got the llvmdev thread in my
e-mail box because I don't subscribe there, which kinda prevents me from
replying to it. Unless there is something I am missing in which I
apologize for being dumb.

If someone involed in the llvmdev thread could reply to it and put me in
copy, I would then be more than happy to discuss it there. I won't have
much to say though, just wanted to contribute the list of features and
their availability to help you all deciding in due knowledge.

-- Matthieu.

Go here and select followup in the top-right:

http://thread.gmane.org/gmane.comp.compilers.llvm.devel/57983