r223186 - Add support for has_feature(cxx_alignof) and has_feature(c_alignof).
Nico Weber
nicolasweber at gmx.de
Tue Dec 2 17:25:49 PST 2014
Author: nico
Date: Tue Dec 2 19:25:49 2014
New Revision: 223186
URL: http://llvm.org/viewvc/llvm-project?rev=223186&view=rev
Log:
Add support for has_feature(cxx_alignof) and has_feature(c_alignof).
r142020 added support for has_feature(cxx_alignas). This does the same for
alignof.
Modified:
cfe/trunk/docs/LanguageExtensions.rst
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/test/Lexer/has_extension.c
cfe/trunk/test/Lexer/has_feature_c1x.c
cfe/trunk/test/Lexer/has_feature_cxx0x.cpp
Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=223186&r1=223185&r2=223186&view=diff
==============================================================================
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Tue Dec 2 19:25:49 2014
@@ -543,6 +543,9 @@ C++11 alignment specifiers
Use ``__has_feature(cxx_alignas)`` or ``__has_extension(cxx_alignas)`` to
determine if support for alignment specifiers using ``alignas`` is enabled.
+Use ``__has_feature(cxx_alignof)`` or ``__has_extension(cxx_alignof)`` to
+determine if support for the ``alignof`` keyword is enabled.
+
C++11 attributes
^^^^^^^^^^^^^^^^
@@ -857,6 +860,9 @@ C11 alignment specifiers
Use ``__has_feature(c_alignas)`` or ``__has_extension(c_alignas)`` to determine
if support for alignment specifiers using ``_Alignas`` is enabled.
+Use ``__has_feature(c_alignof)`` or ``__has_extension(c_alignof)`` to determine
+if support for the ``_Alignof`` keyword is enabled.
+
C11 atomic operations
^^^^^^^^^^^^^^^^^^^^^
Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=223186&r1=223185&r2=223186&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Tue Dec 2 19:25:49 2014
@@ -913,6 +913,7 @@ static bool HasFeature(const Preprocesso
.Case("arc_cf_code_audited", true)
// C11 features
.Case("c_alignas", LangOpts.C11)
+ .Case("c_alignof", LangOpts.C11)
.Case("c_atomic", LangOpts.C11)
.Case("c_generic_selections", LangOpts.C11)
.Case("c_static_assert", LangOpts.C11)
@@ -922,6 +923,7 @@ static bool HasFeature(const Preprocesso
.Case("cxx_access_control_sfinae", LangOpts.CPlusPlus11)
.Case("cxx_alias_templates", LangOpts.CPlusPlus11)
.Case("cxx_alignas", LangOpts.CPlusPlus11)
+ .Case("cxx_alignof", LangOpts.CPlusPlus11)
.Case("cxx_atomic", LangOpts.CPlusPlus11)
.Case("cxx_attributes", LangOpts.CPlusPlus11)
.Case("cxx_auto_type", LangOpts.CPlusPlus11)
@@ -1030,6 +1032,7 @@ static bool HasExtension(const Preproces
return llvm::StringSwitch<bool>(Extension)
// C11 features supported by other languages as extensions.
.Case("c_alignas", true)
+ .Case("c_alignof", true)
.Case("c_atomic", true)
.Case("c_generic_selections", true)
.Case("c_static_assert", true)
Modified: cfe/trunk/test/Lexer/has_extension.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/has_extension.c?rev=223186&r1=223185&r2=223186&view=diff
==============================================================================
--- cfe/trunk/test/Lexer/has_extension.c (original)
+++ cfe/trunk/test/Lexer/has_extension.c Tue Dec 2 19:25:49 2014
@@ -36,6 +36,14 @@ int has_c_alignas();
int no_c_alignas();
#endif
+// CHECK-PED-NONE: has_c_alignof
+// CHECK-PED-ERR: no_c_alignof
+#if __has_extension(c_alignof)
+int has_c_alignof();
+#else
+int no_c_alignof();
+#endif
+
// Arbitrary feature to test that the extension name can be surrounded with
// double underscores.
// CHECK-PED-NONE: has_double_underscores
Modified: cfe/trunk/test/Lexer/has_feature_c1x.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/has_feature_c1x.c?rev=223186&r1=223185&r2=223186&view=diff
==============================================================================
--- cfe/trunk/test/Lexer/has_feature_c1x.c (original)
+++ cfe/trunk/test/Lexer/has_feature_c1x.c Tue Dec 2 19:25:49 2014
@@ -12,7 +12,6 @@ int has_atomic();
#else
int no_atomic();
#endif
-
// CHECK-1X: has_atomic
// CHECK-NO-1X: no_atomic
@@ -21,7 +20,6 @@ int has_static_assert();
#else
int no_static_assert();
#endif
-
// CHECK-1X: has_static_assert
// CHECK-NO-1X: no_static_assert
@@ -30,7 +28,6 @@ int has_generic_selections();
#else
int no_generic_selections();
#endif
-
// CHECK-1X: has_generic_selections
// CHECK-NO-1X: no_generic_selections
@@ -39,10 +36,17 @@ int has_alignas();
#else
int no_alignas();
#endif
-
// CHECK-1X: has_alignas
// CHECK-NO-1X: no_alignas
+#if __has_feature(c_alignof)
+int has_alignof();
+#else
+int no_alignof();
+#endif
+// CHECK-1X: has_alignof
+// CHECK-NO-1X: no_alignof
+
#if __has_feature(c_thread_local)
int has_thread_local();
#else
Modified: cfe/trunk/test/Lexer/has_feature_cxx0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/has_feature_cxx0x.cpp?rev=223186&r1=223185&r2=223186&view=diff
==============================================================================
--- cfe/trunk/test/Lexer/has_feature_cxx0x.cpp (original)
+++ cfe/trunk/test/Lexer/has_feature_cxx0x.cpp Tue Dec 2 19:25:49 2014
@@ -234,6 +234,16 @@ int no_alignas();
// CHECK-11: has_alignas
// CHECK-NO-11: no_alignas
+#if __has_feature(cxx_alignof)
+int has_alignof();
+#else
+int no_alignof();
+#endif
+
+// CHECK-1Y: has_alignof
+// CHECK-11: has_alignof
+// CHECK-NO-11: no_alignof
+
#if __has_feature(cxx_raw_string_literals)
int has_raw_string_literals();
#else
More information about the cfe-commits
mailing list