[clang] [clang][Sema] Track trivial-relocatability as a type trait (PR #84621)

via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 5 12:35:03 PDT 2024


================
@@ -826,6 +842,14 @@ void CXXRecordDecl::addedMember(Decl *D) {
               ? !Constructor->isImplicit()
               : (Constructor->isUserProvided() || Constructor->isExplicit()))
         data().Aggregate = false;
+
+      // A trivially relocatable class is a class:
+      // -- where no eligible copy constructor, move constructor, copy
+      // assignment operator, move assignment operator, or destructor is
+      // user-provided,
+      if (Constructor->isUserProvided() && (Constructor->isCopyConstructor() ||
+                                            Constructor->isMoveConstructor()))
+        data().IsNaturallyTriviallyRelocatable = false;
----------------
sjanel wrote:

If there is a user-defined copy constructor, then it's not trivially copyable anymore. Same goes for moves. So P1144 is more in line with what the standard has chosen in the past. IMO it's better to keep the same principle and not hide things to the developer.

https://github.com/llvm/llvm-project/pull/84621


More information about the cfe-commits mailing list