[PATCH] [Concepts] Add (disabled) __has_feature/extension; NFC

Hubert Tong hubert.reinterpretcast at gmail.com
Sun May 24 17:12:01 PDT 2015


Hi rsmith, faisalv, fraggamuffin,

This adds a commented-out line which would otherwise enable
`__has_feature` and `__has_extension` queries for the Concepts TS and an
equally commented-out section on the Clang Language Extensions page.

http://reviews.llvm.org/D9964

Files:
  docs/LanguageExtensions.rst
  lib/Lex/PPMacroExpansion.cpp
  test/Lexer/has_extension_cxx.cpp
  test/Lexer/has_feature_cxx0x.cpp

Index: docs/LanguageExtensions.rst
===================================================================
--- docs/LanguageExtensions.rst
+++ docs/LanguageExtensions.rst
@@ -873,6 +873,22 @@
 ``__has_extension(cxx_variable_templates)`` to determine if support for
 templated variable declarations is enabled.
 
+..
+  C++ Technical Specifications
+  ----------------------------
+..
+  The features listed below are part of the various C++ Technical Specifications
+  or working papers, preliminary drafts, drafts, etc. thereof. These features
+  may be enabled through the option associated with their respective TS when
+  compiling C++ code.
+..
+  C++ Extensions for Concepts
+  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+..
+  Use ``__has_feature(cxx_experimental_concepts)`` or
+  ``__has_extension(cxx_experimental_concepts)`` to determine if support for
+  the C++ extensions for concepts is enabled.
+
 C11
 ---
 
Index: lib/Lex/PPMacroExpansion.cpp
===================================================================
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -1163,7 +1163,7 @@
       .Case("cxx_variable_templates", LangOpts.CPlusPlus14)
       // C++ TSes
       //.Case("cxx_runtime_arrays", LangOpts.CPlusPlusTSArrays)
-      //.Case("cxx_concepts", LangOpts.CPlusPlusTSConcepts)
+      //.Case("cxx_experimental_concepts", LangOpts.ConceptsTS)
       // FIXME: Should this be __has_feature or __has_extension?
       //.Case("raw_invocation_type", LangOpts.CPlusPlus)
       // Type traits
Index: test/Lexer/has_extension_cxx.cpp
===================================================================
--- test/Lexer/has_extension_cxx.cpp
+++ test/Lexer/has_extension_cxx.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -std=c++98 -E %s -o - | FileCheck %s
 // RUN: %clang_cc1 -std=c++11 -E %s -o - | FileCheck %s --check-prefix=CHECK11
+// RUN: %clang_cc1 -std=c++14 -E %s -o - | FileCheck %s --check-prefix=CHECK14
+// RUN: %clang_cc1 -std=c++1z -E %s -o - | FileCheck %s --check-prefix=CHECK1Z
 
 // CHECK: c_static_assert
 #if __has_extension(c_static_assert)
@@ -66,3 +68,11 @@
 #if __has_extension(cxx_init_captures)
 int has_init_captures();
 #endif
+
+// CHECK-NOT: has_experimental_concepts
+// CHECK11-NOT: has_experimental_concepts
+// CHECK14-NOT: has_experimental_concepts
+// CHECK1Z-NOT: has_experimental_concepts
+#if __has_extension(cxx_experimental_concepts)
+int has_experimental_concepts();
+#endif
Index: test/Lexer/has_feature_cxx0x.cpp
===================================================================
--- test/Lexer/has_feature_cxx0x.cpp
+++ test/Lexer/has_feature_cxx0x.cpp
@@ -468,3 +468,14 @@
 // CHECK-14: has_generic_lambdas
 // CHECK-11: no_generic_lambdas
 // CHECK-NO-11: no_generic_lambdas
+
+#if __has_feature(cxx_experimental_concepts)
+int has_experimental_concepts();
+#else
+int no_experimental_concepts();
+#endif
+
+// CHECK-1Z: no_experimental_concepts
+// CHECK-14: no_experimental_concepts
+// CHECK-11: no_experimental_concepts
+// CHECK-NO-11: no_experimental_concepts

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9964.26389.patch
Type: text/x-patch
Size: 3029 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150525/6aafb326/attachment.bin>


More information about the cfe-commits mailing list