r221816 - Update Clang's SD-6 support to match N4200 (except for __has_cpp_attribute,

Richard Smith richard-llvm at metafoo.co.uk
Wed Nov 12 13:16:38 PST 2014


Author: rsmith
Date: Wed Nov 12 15:16:38 2014
New Revision: 221816

URL: http://llvm.org/viewvc/llvm-project?rev=221816&view=rev
Log:
Update Clang's SD-6 support to match N4200 (except for __has_cpp_attribute,
which we don't yet implement).

Modified:
    cfe/trunk/docs/LanguageExtensions.rst
    cfe/trunk/lib/Frontend/InitPreprocessor.cpp
    cfe/trunk/test/Lexer/cxx-features.cpp
    cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=221816&r1=221815&r2=221816&view=diff
==============================================================================
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Wed Nov 12 15:16:38 2014
@@ -458,6 +458,13 @@ features are enabled.  The ``__has_exten
 language features are available as an extension when compiling for a standard
 which does not provide them.  The features which can be tested are listed here.
 
+Since Clang 3.4, the C++ SD-6 feature test macros are also supported.
+These are macros with names of the form ``__cpp_<feature_name>``, and are
+intended to be a portable way to query the supported features of the compiler.
+See `the C++ status page <http://clang.llvm.org/cxx_status.html#ts>`_ for
+information on the version of SD-6 supported by each Clang release, and the
+macros provided by that revision of the recommendations.
+
 C++98
 -----
 
@@ -751,6 +758,13 @@ Use ``__has_feature(cxx_aggregate_nsdmi)
 ``__has_extension(cxx_aggregate_nsdmi)`` to determine if support
 for default initializers in aggregate members is enabled.
 
+C++1y digit separators
+^^^^^^^^^^^^^^^^^^^^^^
+
+Use ``__cpp_digit_separators`` to determine if support for digit separators
+using single quotes (for instance, ``10'000``) is enabled. At this time, there
+is no corresponding ``__has_feature`` name
+
 C++1y generalized lambda capture
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=221816&r1=221815&r2=221816&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Wed Nov 12 15:16:38 2014
@@ -409,6 +409,12 @@ static void InitializeStandardPredefined
 /// ISO/IEC JTC1/SC22/WG21 (C++) SD-6: "SG10 Feature Test Recommendations".
 static void InitializeCPlusPlusFeatureTestMacros(const LangOptions &LangOpts,
                                                  MacroBuilder &Builder) {
+  // C++98 features.
+  if (LangOpts.RTTI)
+    Builder.defineMacro("__cpp_rtti", "199711");
+  if (LangOpts.CXXExceptions)
+    Builder.defineMacro("__cpp_exceptions", "199711");
+
   // C++11 features.
   if (LangOpts.CPlusPlus11) {
     Builder.defineMacro("__cpp_unicode_characters", "200704");
@@ -418,16 +424,24 @@ static void InitializeCPlusPlusFeatureTe
     Builder.defineMacro("__cpp_lambdas", "200907");
     Builder.defineMacro("__cpp_constexpr",
                         LangOpts.CPlusPlus14 ? "201304" : "200704");
+    Builder.defineMacro("__cpp_range_based_for", "200907");
     Builder.defineMacro("__cpp_static_assert", "200410");
     Builder.defineMacro("__cpp_decltype", "200707");
     Builder.defineMacro("__cpp_attributes", "200809");
     Builder.defineMacro("__cpp_rvalue_references", "200610");
     Builder.defineMacro("__cpp_variadic_templates", "200704");
+    Builder.defineMacro("__cpp_initializer_lists", "200806");
+    Builder.defineMacro("__cpp_delegating_constructors", "200604");
+    Builder.defineMacro("__cpp_nsdmi", "200809");
+    Builder.defineMacro("__cpp_inheriting_constructors", "200802");
+    Builder.defineMacro("__cpp_ref_qualifiers", "200710");
+    Builder.defineMacro("__cpp_alias_templates", "200704");
   }
 
   // C++14 features.
   if (LangOpts.CPlusPlus14) {
     Builder.defineMacro("__cpp_binary_literals", "201304");
+    Builder.defineMacro("__cpp_digit_separators", "201309");
     Builder.defineMacro("__cpp_init_captures", "201304");
     Builder.defineMacro("__cpp_generic_lambdas", "201304");
     Builder.defineMacro("__cpp_decltype_auto", "201304");
@@ -435,6 +449,8 @@ static void InitializeCPlusPlusFeatureTe
     Builder.defineMacro("__cpp_aggregate_nsdmi", "201304");
     Builder.defineMacro("__cpp_variable_templates", "201304");
   }
+  if (LangOpts.SizedDeallocation)
+    Builder.defineMacro("__cpp_sized_deallocation", "201309");
 }
 
 static void InitializePredefinedMacros(const TargetInfo &TI,

Modified: cfe/trunk/test/Lexer/cxx-features.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/cxx-features.cpp?rev=221816&r1=221815&r2=221816&view=diff
==============================================================================
--- cfe/trunk/test/Lexer/cxx-features.cpp (original)
+++ cfe/trunk/test/Lexer/cxx-features.cpp Wed Nov 12 15:16:38 2014
@@ -16,6 +16,10 @@
 #error "wrong value for __cpp_binary_literals"
 #endif
 
+#if check(digit_separators, 0, 0, 201309)
+#error "wrong value for __cpp_digit_separators"
+#endif
+
 #if check(init_captures, 0, 0, 201304)
 #error "wrong value for __cpp_init_captures"
 #endif
@@ -24,6 +28,10 @@
 #error "wrong value for __cpp_generic_lambdas"
 #endif
 
+#if check(sized_deallocation, 0, 0, 201309)
+#error "wrong value for __cpp_sized_deallocation"
+#endif
+
 #if check(constexpr, 0, 200704, 201304)
 #error "wrong value for __cpp_constexpr"
 #endif
@@ -68,6 +76,10 @@
 #error "wrong value for __cpp_lambdas"
 #endif
 
+#if check(range_based_for, 0, 200907, 200907)
+#error "wrong value for __cpp_range_based_for"
+#endif
+
 #if check(static_assert, 0, 200410, 200410)
 #error "wrong value for __cpp_static_assert"
 #endif
@@ -87,3 +99,27 @@
 #if check(variadic_templates, 0, 200704, 200704)
 #error "wrong value for __cpp_variadic_templates"
 #endif
+
+#if check(initializer_lists, 0, 200806, 200806)
+#error "wrong value for __cpp_initializer_lists"
+#endif
+
+#if check(delegating_constructors, 0, 200604, 200604)
+#error "wrong value for __cpp_delegating_constructors"
+#endif
+
+#if check(nsdmi, 0, 200809, 200809)
+#error "wrong value for __cpp_nsdmi"
+#endif
+
+#if check(inheriting_constructors, 0, 200802, 200802)
+#error "wrong value for __cpp_inheriting_constructors"
+#endif
+
+#if check(ref_qualifiers, 0, 200710, 200710)
+#error "wrong value for __cpp_ref_qualifiers"
+#endif
+
+#if check(alias_templates, 0, 200704, 200704)
+#error "wrong value for __cpp_alias_templates"
+#endif

Modified: cfe/trunk/www/cxx_status.html
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_status.html?rev=221816&r1=221815&r2=221816&view=diff
==============================================================================
--- cfe/trunk/www/cxx_status.html (original)
+++ cfe/trunk/www/cxx_status.html Wed Nov 12 15:16:38 2014
@@ -583,9 +583,16 @@ Clang version they became available:</p>
     <th>Available in Clang?</th>
  </tr>
     <tr>
-      <td>SD-6: SG10 feature test recommendations</td>
-      <td><a href="http://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations">SD-6</a></td>
-      <td class="full" align="center">Clang 3.4 (<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3745">N3745</a>)</td>
+      <td rowspan="2">SD-6: SG10 feature test recommendations</td>
+      <td rowspan="2"><a href="http://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations">SD-6</a></td>
+      <td class="full" align="center">
+        Clang 3.4 (<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3745">N3745</a>)</br>
+      </td>
+    </tr>
+    <tr>
+      <td class="partial" align="center">
+        SVN (<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4200">N4200</a>): Partial <a href="#n4200">(1)</a>
+      </td>
     </tr>
     <tr>
       <td>[DRAFT TS] Array extensions (arrays of runtime bound)</td>
@@ -604,6 +611,10 @@ Clang version they became available:</p>
     </tr>
 </table>
 
+<p>
+<span id="n4200">(1): <code>__has_cpp_attribute</code> is not yet supported.</span>
+</p>
+
 </div>
 </body>
 </html>





More information about the cfe-commits mailing list