[all-commits] [llvm/llvm-project] 0b89d1: [Sema] Add deprecation warnings for some compiler ...

Roy Jacobson via All-commits all-commits at lists.llvm.org
Tue Jul 12 09:24:33 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0b89d1d59f82cf5b45c250cd5c3351e43ce35ef9
      https://github.com/llvm/llvm-project/commit/0b89d1d59f82cf5b45c250cd5c3351e43ce35ef9
  Author: Roy Jacobson <roi.jacobson1 at gmail.com>
  Date:   2022-07-12 (Tue, 12 Jul 2022)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Basic/DiagnosticGroups.td
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/lib/Sema/SemaExprCXX.cpp
    M clang/test/CXX/dcl.decl/dcl.init/p5.cpp
    M clang/test/CXX/drs/dr18xx.cpp
    M clang/test/CXX/drs/dr21xx.cpp
    M clang/test/CXX/special/class.copy/p12-0x.cpp
    M clang/test/CXX/special/class.copy/p25-0x.cpp
    M clang/test/CXX/special/class.ctor/p5-0x.cpp
    M clang/test/Modules/cxx-decls.cpp
    M clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
    M clang/test/SemaCXX/cxx11-crashes.cpp
    A clang/test/SemaCXX/deprecated-builtins.cpp
    M clang/test/SemaCXX/sizeless-1.cpp
    M clang/test/SemaCXX/trivial-constructor.cpp
    M clang/test/SemaCXX/trivial-destructor.cpp
    M clang/test/SemaCXX/type-traits.cpp
    M clang/test/SemaObjCXX/arc-type-traits.mm
    M clang/test/SemaObjCXX/objc-weak-type-traits.mm

  Log Message:
  -----------
  [Sema] Add deprecation warnings for some compiler provided __has_* type traits

Some compiler provided type traits like __has_trivial_constructor have been documented
as deprecated for quite some time.
Still, some people apparently still use them, even though mixing them with concepts
and with deleted functions leads to weird results. There's also disagreement about some
edge cases between GCC (which Clang claims to follow) and MSVC.

This patch adds deprecation warnings for the usage of those builtins, except for __has_trivial_destructor
which doesn't have a GCC alternative.

I made the warning on by default, so I had to silence it for some tests but it's not too many.

Some (decade old) history of issues with those builtins:
https://github.com/llvm/llvm-project/issues/18187
https://github.com/llvm/llvm-project/issues/18559
https://github.com/llvm/llvm-project/issues/22161
https://github.com/llvm/llvm-project/issues/33063

The abseil usage of them that triggered me to add this warning:
https://github.com/abseil/abseil-cpp/issues/1201

Weird interaction of those builtins with C++20's conditionally trivial special member functions:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106085

Reviewed By: #clang-language-wg, aaron.ballman

Differential Revision: https://reviews.llvm.org/D129170




More information about the All-commits mailing list