[llvm-branch-commits] [clang] 5b93812 - __has_trivial_copy should map to __is_trivially_copyable

Tobias Hieta via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Aug 15 00:40:36 PDT 2022


Author: Zachary Henkel
Date: 2022-08-15T09:40:11+02:00
New Revision: 5b93812e72dde46079e73deef8bd596e7f907fac

URL: https://github.com/llvm/llvm-project/commit/5b93812e72dde46079e73deef8bd596e7f907fac
DIFF: https://github.com/llvm/llvm-project/commit/5b93812e72dde46079e73deef8bd596e7f907fac.diff

LOG:  __has_trivial_copy should map to __is_trivially_copyable

Found during clang 15 RC1 testing due to the new diagnostic added by @royjacobson since clang 14.  Uncertain if this fix meets the bar to also be applied to the release branch.

If accepted, I'll need someone with commit access to submit on my behalf.

Reviewed By: royjacobson, aaron.ballman, erichkeane

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

(cherry picked from commit 64f0f7e6460019a38fe2f1cbe4b9446a3268af18)

Added: 
    

Modified: 
    clang/docs/LanguageExtensions.rst
    clang/lib/Sema/SemaExprCXX.cpp
    clang/test/SemaCXX/deprecated-builtins.cpp

Removed: 
    


################################################################################
diff  --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst
index 6b8b88020ed0..de305ce79c24 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1375,7 +1375,7 @@ The following type trait primitives are supported by Clang. Those traits marked
 * ``__has_trivial_move_assign`` (GNU, Microsoft):
   Deprecated, use ``__is_trivially_assignable`` instead.
 * ``__has_trivial_copy`` (GNU, Microsoft):
-  Deprecated, use ``__is_trivially_constructible`` instead.
+  Deprecated, use ``__is_trivially_copyable`` instead.
 * ``__has_trivial_constructor`` (GNU, Microsoft):
   Deprecated, use ``__is_trivially_constructible`` instead.
 * ``__has_trivial_move_constructor`` (GNU, Microsoft):

diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 5331193de863..6f9e025283f5 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -5412,6 +5412,8 @@ void DiagnoseBuiltinDeprecation(Sema& S, TypeTrait Kind,
       Replacement = BTT_IsTriviallyAssignable;
       break;
     case UTT_HasTrivialCopy:
+      Replacement = UTT_IsTriviallyCopyable;
+      break;
     case UTT_HasTrivialDefaultConstructor:
     case UTT_HasTrivialMoveConstructor:
       Replacement = TT_IsTriviallyConstructible;

diff  --git a/clang/test/SemaCXX/deprecated-builtins.cpp b/clang/test/SemaCXX/deprecated-builtins.cpp
index 2bb687c1ef12..849b9b014fff 100644
--- a/clang/test/SemaCXX/deprecated-builtins.cpp
+++ b/clang/test/SemaCXX/deprecated-builtins.cpp
@@ -11,7 +11,7 @@ void f() {
     a = __has_nothrow_constructor(A);  // expected-warning-re {{__has_nothrow_constructor {{.*}} use __is_nothrow_constructible}}
     a = __has_trivial_assign(A);  // expected-warning-re {{__has_trivial_assign {{.*}} use __is_trivially_assignable}}
     a = __has_trivial_move_assign(A);  // expected-warning-re {{__has_trivial_move_assign {{.*}} use __is_trivially_assignable}}
-    a = __has_trivial_copy(A);  // expected-warning-re {{__has_trivial_copy {{.*}} use __is_trivially_constructible}}
+    a = __has_trivial_copy(A);  // expected-warning-re {{__has_trivial_copy {{.*}} use __is_trivially_copyable}}
     a = __has_trivial_constructor(A);  // expected-warning-re {{__has_trivial_constructor {{.*}} use __is_trivially_constructible}}
     a = __has_trivial_move_constructor(A);  // expected-warning-re {{__has_trivial_move_constructor {{.*}} use __is_trivially_constructible}}
     a = __has_trivial_destructor(A);  // expected-warning-re {{__has_trivial_destructor {{.*}} use __is_trivially_destructible}}


        


More information about the llvm-branch-commits mailing list