From e6e68b53778bb5a15c10a73a5bf18d8ab73f75e3 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Fri, 19 Apr 2013 17:00:31 +0000 Subject: [PATCH] C++11 support is now feature-complete. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179861 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/LanguageExtensions.rst | 15 +++++++++++++-- lib/Lex/PPMacroExpansion.cpp | 4 +++- test/Lexer/has_feature_c1x.c | 9 +++++++++ test/Lexer/has_feature_cxx0x.cpp | 18 ++++++++++++++++++ www/cxx_status.html | 10 +++++++--- www/index.html | 2 +- 6 files changed, 51 insertions(+), 7 deletions(-) diff --git a/docs/LanguageExtensions.rst b/docs/LanguageExtensions.rst index c870d20b8763..dbb67f908d13 100644 --- a/docs/LanguageExtensions.rst +++ b/docs/LanguageExtensions.rst @@ -645,8 +645,7 @@ C++11 inheriting constructors ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use ``__has_feature(cxx_inheriting_constructors)`` to determine if support for -inheriting constructors is enabled. Clang does not currently implement this -feature. +inheriting constructors is enabled. C++11 inline namespaces ^^^^^^^^^^^^^^^^^^^^^^^ @@ -727,6 +726,12 @@ Use ``__has_feature(cxx_static_assert)`` or ``__has_extension(cxx_static_assert)`` to determine if support for compile-time assertions using ``static_assert`` is enabled. +C++11 ``thread_local`` +^^^^^^^^^^^^^^^^^^^^^^ + +Use ``__has_feature(cxx_thread_local)`` to determine if support for +``thread_local`` variables is enabled. + C++11 type inference ^^^^^^^^^^^^^^^^^^^^ @@ -818,6 +823,12 @@ Use ``__has_feature(c_static_assert)`` or ``__has_extension(c_static_assert)`` to determine if support for compile-time assertions using ``_Static_assert`` is enabled. +C11 ``_Thread_local`` +^^^^^^^^^^^^^^^^^^^^^ + +Use ``__has_feature(c_thread_local)`` to determine if support for +``_Thread_local`` variables is enabled. + Checks for Type Traits ====================== diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp index 21451f581f3a..9a530c68018b 100644 --- a/lib/Lex/PPMacroExpansion.cpp +++ b/lib/Lex/PPMacroExpansion.cpp @@ -751,6 +751,7 @@ static bool HasFeature(const Preprocessor &PP, const IdentifierInfo *II) { .Case("c_atomic", LangOpts.C11) .Case("c_generic_selections", LangOpts.C11) .Case("c_static_assert", LangOpts.C11) + .Case("c_thread_local", LangOpts.C11) // C++11 features .Case("cxx_access_control_sfinae", LangOpts.CPlusPlus11) .Case("cxx_alias_templates", LangOpts.CPlusPlus11) @@ -768,7 +769,7 @@ static bool HasFeature(const Preprocessor &PP, const IdentifierInfo *II) { .Case("cxx_explicit_conversions", LangOpts.CPlusPlus11) .Case("cxx_generalized_initializers", LangOpts.CPlusPlus11) .Case("cxx_implicit_moves", LangOpts.CPlusPlus11) - //.Case("cxx_inheriting_constructors", false) + .Case("cxx_inheriting_constructors", LangOpts.CPlusPlus11) .Case("cxx_inline_namespaces", LangOpts.CPlusPlus11) .Case("cxx_lambdas", LangOpts.CPlusPlus11) .Case("cxx_local_type_template_args", LangOpts.CPlusPlus11) @@ -782,6 +783,7 @@ static bool HasFeature(const Preprocessor &PP, const IdentifierInfo *II) { .Case("cxx_rvalue_references", LangOpts.CPlusPlus11) .Case("cxx_strong_enums", LangOpts.CPlusPlus11) .Case("cxx_static_assert", LangOpts.CPlusPlus11) + .Case("cxx_thread_local", LangOpts.CPlusPlus11) .Case("cxx_trailing_return", LangOpts.CPlusPlus11) .Case("cxx_unicode_literals", LangOpts.CPlusPlus11) .Case("cxx_unrestricted_unions", LangOpts.CPlusPlus11) diff --git a/test/Lexer/has_feature_c1x.c b/test/Lexer/has_feature_c1x.c index c9a5f56ddf3a..fe2640bbda33 100644 --- a/test/Lexer/has_feature_c1x.c +++ b/test/Lexer/has_feature_c1x.c @@ -37,6 +37,15 @@ int no_alignas(); // CHECK-1X: has_alignas // CHECK-NO-1X: no_alignas +#if __has_feature(c_thread_local) +int has_thread_local(); +#else +int no_thread_local(); +#endif + +// CHECK-1X: has_thread_local +// CHECK-NO-1X: no_thread_local + #if __STDC_VERSION__ > 199901L int is_c1x(); #else diff --git a/test/Lexer/has_feature_cxx0x.cpp b/test/Lexer/has_feature_cxx0x.cpp index 8e0222dcecd5..d68675afcf59 100644 --- a/test/Lexer/has_feature_cxx0x.cpp +++ b/test/Lexer/has_feature_cxx0x.cpp @@ -272,3 +272,21 @@ int no_local_type_template_args(); // CHECK-0X: has_local_type_template_args // CHECK-NO-0X: no_local_type_template_args + +#if __has_feature(cxx_inheriting_constructors) +int has_inheriting_constructors(); +#else +int no_inheriting_constructors(); +#endif + +// CHECK-0X: has_inheriting_constructors +// CHECK-NO-0X: no_inheriting_constructors + +#if __has_feature(cxx_thread_local) +int has_thread_local(); +#else +int no_thread_local(); +#endif + +// CHECK-0X: has_thread_local +// CHECK-NO-0X: no_thread_local diff --git a/www/cxx_status.html b/www/cxx_status.html index 715efda47e74..e37ee565ca1e 100644 --- a/www/cxx_status.html +++ b/www/cxx_status.html @@ -37,7 +37,10 @@

C++98 implementation status

C++11 implementation status

-

Clang provides support for a number of features included in the new ISO C++ Standard, ISO/IEC 14882:2011. The following table describes which C++11 features have been implemented in Clang and in which Clang versions they became available.

+

Clang implements all of the ISO + C++ 2011 standard. The following table describes the Clang version + in which each feature became available.

By default, Clang builds C++ code according to the C++98 standard, with many C++11 features accepted as extensions. You can use Clang in C++11 mode with the @@ -47,7 +50,8 @@

C++11 implementation status

work with Clang in C++11 mode. Patches are also needed to make libstdc++-4.6, and libstdc++-4.7 work with Clang -releases prior to version 3.2 in C++11 mode.

+releases prior to version 3.2 in C++11 mode. thread_local support +currently requires g++-4.8's C++ runtime library.

@@ -349,7 +353,7 @@

C++11 implementation status

- + diff --git a/www/index.html b/www/index.html index 6455262a461a..23d82e3ce078 100644 --- a/www/index.html +++ b/www/index.html @@ -94,7 +94,7 @@

Current Status

targeting X86-32, X86-64, and ARM (other targets may have caveats, but are usually easy to fix). If you are looking for source analysis or source-to-source transformation tools, clang is probably a great - solution for you. Clang supports most of C++11, please see the C++ status page for more information.

Thread-local storage N2659NoSVN
Dynamic initialization and destruction with concurrency