summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorJF Bastien <jfbastien@apple.com>2019-08-14 17:39:07 +0000
committerJF Bastien <jfbastien@apple.com>2019-08-14 17:39:07 +0000
commitb13c8ca9ebc4bfa4a916c46ff1415d3092be136c (patch)
tree698fede5907e302e8687521c5e973b97c7082605 /llvm
parent04ddff4cbc91be6a2dfd4dbbf3563762c4895d68 (diff)
downloadbcm5719-llvm-b13c8ca9ebc4bfa4a916c46ff1415d3092be136c.tar.gz
bcm5719-llvm-b13c8ca9ebc4bfa4a916c46ff1415d3092be136c.zip
Move to C++14
Summary: I just bumped the minimum compiler versions to support C++14 in D66188. Following [our process](http://llvm.org/docs/DeveloperPolicy.html#toolchain) and [our previous agreement](http://lists.llvm.org/pipermail/llvm-dev/2019-January/129452.html), I'm now officially bumping the C++ version to 14 and updating the documentation. Subscribers: mgorny, jkorous, dexonsmith, llvm-commits, chandlerc, thakis, EricWF, jyknight, lhames, JDevlieghere Tags: #llvm Differential Revision: https://reviews.llvm.org/D66195 llvm-svn: 368887
Diffstat (limited to 'llvm')
-rw-r--r--llvm/cmake/modules/HandleLLVMOptions.cmake2
-rw-r--r--llvm/docs/CodingStandards.rst104
-rw-r--r--llvm/include/llvm/Support/Compiler.h6
-rw-r--r--llvm/include/llvm/Support/type_traits.h2
4 files changed, 16 insertions, 98 deletions
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index a243507791a..a493f1dde88 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -18,7 +18,7 @@ else()
set(LINKER_IS_LLD_LINK FALSE)
endif()
-set(LLVM_CXX_STD_default "c++11")
+set(LLVM_CXX_STD_default "c++14")
# Preserve behaviour of legacy cache variables
if (LLVM_ENABLE_CXX1Y)
set(LLVM_CXX_STD_default "c++1y")
diff --git a/llvm/docs/CodingStandards.rst b/llvm/docs/CodingStandards.rst
index 781b6bdae09..f1873c92da1 100644
--- a/llvm/docs/CodingStandards.rst
+++ b/llvm/docs/CodingStandards.rst
@@ -56,12 +56,12 @@ choice.
C++ Standard Versions
---------------------
-LLVM, Clang, and LLD are currently written using C++11 conforming code,
+LLVM, Clang, and LLD are currently written using C++14 conforming code,
although we restrict ourselves to features which are available in the major
toolchains supported as host compilers. The LLDB project is even more
aggressive in the set of host compilers supported and thus uses still more
features. Regardless of the supported features, code is expected to (when
-reasonable) be standard, portable, and modern C++11 code. We avoid unnecessary
+reasonable) be standard, portable, and modern C++14 code. We avoid unnecessary
vendor-specific extensions, etc.
C++ Standard Library
@@ -78,10 +78,10 @@ There are some exceptions such as the standard I/O streams library which are
avoided. Also, there is much more detailed information on these subjects in the
:doc:`ProgrammersManual`.
-Supported C++11 Language and Library Features
+Supported C++14 Language and Library Features
---------------------------------------------
-While LLVM, Clang, and LLD use C++11, not all features are available in all of
+While LLVM, Clang, and LLD use C++14, not all features are available in all of
the toolchains which we support. The set of features supported for use in LLVM
is the intersection of those supported in the minimum requirements described
in the :doc:`GettingStarted` page, section `Software`.
@@ -92,100 +92,9 @@ guidance below to help you know what to expect.
Each toolchain provides a good reference for what it accepts:
* Clang: https://clang.llvm.org/cxx_status.html
-* GCC: https://gcc.gnu.org/projects/cxx-status.html#cxx11
+* GCC: https://gcc.gnu.org/projects/cxx-status.html#cxx14
* MSVC: https://msdn.microsoft.com/en-us/library/hh567368.aspx
-In most cases, the MSVC list will be the dominating factor. Here is a summary
-of the features that are expected to work. Features not on this list are
-unlikely to be supported by our host compilers.
-
-* Rvalue references: N2118_
-
- * But *not* Rvalue references for ``*this`` or member qualifiers (N2439_)
-
-* Static assert: N1720_
-* ``auto`` type deduction: N1984_, N1737_
-* Trailing return types: N2541_
-* Lambdas: N2927_
-
- * But *not* lambdas with default arguments.
-
-* ``decltype``: N2343_
-* Nested closing right angle brackets: N1757_
-* Extern templates: N1987_
-* ``nullptr``: N2431_
-* Strongly-typed and forward declarable enums: N2347_, N2764_
-* Local and unnamed types as template arguments: N2657_
-* Range-based for-loop: N2930_
-
- * But ``{}`` are required around inner ``do {} while()`` loops. As a result,
- ``{}`` are required around function-like macros inside range-based for
- loops.
-
-* ``override`` and ``final``: N2928_, N3206_, N3272_
-* Atomic operations and the C++11 memory model: N2429_
-* Variadic templates: N2242_
-* Explicit conversion operators: N2437_
-* Defaulted and deleted functions: N2346_
-* Initializer lists: N2627_
-* Delegating constructors: N1986_
-* Default member initializers (non-static data member initializers): N2756_
-
- * Feel free to use these wherever they make sense and where the `=`
- syntax is allowed. Don't use braced initialization syntax.
-
-.. _N2118: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2118.html
-.. _N2439: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2439.htm
-.. _N1720: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1720.html
-.. _N1984: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1984.pdf
-.. _N1737: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1737.pdf
-.. _N2541: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2541.htm
-.. _N2927: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2927.pdf
-.. _N2343: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2343.pdf
-.. _N1757: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1757.html
-.. _N1987: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1987.htm
-.. _N2431: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2431.pdf
-.. _N2347: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2347.pdf
-.. _N2764: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2764.pdf
-.. _N2657: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm
-.. _N2930: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2930.html
-.. _N2928: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2928.htm
-.. _N3206: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3206.htm
-.. _N3272: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3272.htm
-.. _N2429: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2429.htm
-.. _N2242: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2242.pdf
-.. _N2437: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2437.pdf
-.. _N2346: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm
-.. _N2627: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2672.htm
-.. _N1986: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1986.pdf
-.. _N2756: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2756.htm
-
-The supported features in the C++11 standard libraries are less well tracked,
-but also much greater. Most of the standard libraries implement most of C++11's
-library. The most likely lowest common denominator is Linux support. For
-libc++, the support is just poorly tested and undocumented but expected to be
-largely complete. YMMV. For libstdc++, the support is documented in detail in
-`the libstdc++ manual`_. There are some very minor missing facilities that are
-unlikely to be common problems, and there are a few larger gaps that are worth
-being aware of:
-
-* Not all of the type traits are implemented
-* No regular expression library.
-* While most of the atomics library is well implemented, the fences are
- missing. Fortunately, they are rarely needed.
-* The locale support is incomplete.
-
-Other than these areas you should assume the standard library is available and
-working as expected until some build bot tells you otherwise. If you're in an
-uncertain area of one of the above points, but you cannot test on a Linux
-system, your best approach is to minimize your use of these features, and watch
-the Linux build bots to find out if your usage triggered a bug. For example, if
-you hit a type trait which doesn't work we can then add support to LLVM's
-traits header to emulate it.
-
-.. _the libstdc++ manual:
- https://gcc.gnu.org/onlinedocs/gcc-4.8.0/libstdc++/manual/manual/status.html#status.iso.2011
-
Other Languages
---------------
@@ -808,6 +717,9 @@ type is already obvious from the context. Another time when ``auto`` works well
for these purposes is when the type would have been abstracted away anyways,
often behind a container's typedef such as ``std::vector<T>::iterator``.
+Similarly, C++14 adds generic lambda expressions where parameter types can be
+``auto``. Use these where you would have used a template.
+
Beware unnecessary copies with ``auto``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h
index 43114ad3a43..4deac94f588 100644
--- a/llvm/include/llvm/Support/Compiler.h
+++ b/llvm/include/llvm/Support/Compiler.h
@@ -43,6 +43,12 @@
# define __has_builtin(x) 0
#endif
+#ifdef __cplusplus
+# if __cplusplus < 201402L
+# error Expected C++14 or later.
+# endif
+#endif
+
/// \macro LLVM_GNUC_PREREQ
/// Extend the default __GNUC_PREREQ even if glibc's features.h isn't
/// available.
diff --git a/llvm/include/llvm/Support/type_traits.h b/llvm/include/llvm/Support/type_traits.h
index b9d29f38187..403bac7260b 100644
--- a/llvm/include/llvm/Support/type_traits.h
+++ b/llvm/include/llvm/Support/type_traits.h
@@ -192,7 +192,7 @@ class is_trivially_copyable<T*> : public std::true_type {
// If the compiler supports detecting whether a class is final, define
// an LLVM_IS_FINAL macro. If it cannot be defined properly, this
// macro will be left undefined.
-#if __cplusplus >= 201402L || defined(_MSC_VER)
+#if defined(__cplusplus) || defined(_MSC_VER)
#define LLVM_IS_FINAL(Ty) std::is_final<Ty>()
#elif __has_feature(is_final) || LLVM_GNUC_PREREQ(4, 7, 0)
#define LLVM_IS_FINAL(Ty) __is_final(Ty)
OpenPOWER on IntegriCloud