[PATCH] D48912: [libc++] Add deprecated attributes to many deprecated components

Eric Fiselier via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 3 20:57:24 PDT 2018


EricWF requested changes to this revision.
EricWF added a comment.

We'll also want tests that very the deprecated diagnostics are emitted correctly. To test for the production of diagnostics, Libc++ uses `*.fail.cpp` tests along with Clang Verify <https://clang.llvm.org/doxygen/classclang_1_1VerifyDiagnosticConsumer.html#details>.
I went ahead and implemented `depr.adaptors.cxx11.fail.cpp` <https://gist.github.com/EricWF/6355d7d59718fb749c718d3f605cfa9b> which tests that no diagnostics are emitted in C++03, and the correct diagnostics are emitted in C++11 and beyond.



================
Comment at: libcxx/include/__config:988
 #if _LIBCPP_STD_VER > 11
-#  define _LIBCPP_DEPRECATED [[deprecated]]
+#  define _LIBCPP_DEPRECATED __attribute__((deprecated))
 #else
----------------
Why are we switching the attribute from its C++11 form?

I suspect this will break MSVC builds, or other compilers that don't provide GNU attributes.


================
Comment at: libcxx/include/__config:993
 
+#if _LIBCPP_STD_VER >= 11
+#  define _LIBCPP_DEPRECATED_IN_CXX11 __attribute__((deprecated))
----------------
So here's a quirk you'll need to learn.

`_LIBCPP_STD_VER` is never less than 11, even in C++03 mode, because libc++ attempts to provide a feature complete C++11 implementation regardless of the actual language dialect.

Therefore, this macro marks C++03 components as deprecated in C++03 :-(

The macro you want to use to detect pre-C++11 is `defined(_LIBCPP_CXX03_LANG)`.


================
Comment at: libcxx/include/__functional_base:27
 
+// TODO(ldionne): Mark this as deprecated in C++11 and remove in C++17.
 template <class _Arg1, class _Arg2, class _Result>
----------------
No `TODO`s in headers please, unless the intent is to remove them before the end of the review.
Instead, you should file a bug regarding the work to be done.


I know I've been guilty of this, but it's never too late to change.


================
Comment at: libcxx/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp:26
 
+#ifdef __clang__
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
----------------
How do these tests work with compilers other than Clang?

Perhaps you can add a `disable_deprecated_declarations.h` header, and include that instead? That way the one header can be made to handle most compilers.


Repository:
  rL LLVM

https://reviews.llvm.org/D48912





More information about the llvm-commits mailing list