[PATCH] D128619: [Clang] Implement P0848 (Conditionally Trivial Special Member Functions)

Corentin Jabot via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 20 05:43:49 PDT 2022


cor3ntin added inline comments.


================
Comment at: clang/lib/Sema/SemaDecl.cpp:17870
+///   parameter type and the same cv-qualifiers and ref-qualifier, if any.
+bool AreSpecialMemberFunctionsSameKind(CXXMethodDecl *M1, CXXMethodDecl *M2,
+                     Sema::CXXSpecialMember CSM) {
----------------



================
Comment at: clang/lib/Sema/SemaDecl.cpp:17888
+///   [CWG2595], if any, are satisfied is more constrained.
+void SetEligibleMethods(Sema &S, CXXRecordDecl* Record,
+                        ArrayRef<CXXMethodDecl *> Methods,
----------------



================
Comment at: clang/lib/Sema/SemaDecl.cpp:17960-17961
+        }
+        if (AnotherMethodIsMoreConstrained)
+          break;
+      }
----------------
royjacobson wrote:
> cor3ntin wrote:
> > Is that codepath ever taken?
> > I wonder if there is a way to do that that is not n^2. Maybe not.
> It's not, I didn't mean to leave it there. Thanks for the catch :)
> 
> 
> Generally finding a maximal set in a partial ordering is O(n^2) in the worst case which is when no two objects are comparable.
> 
> We could optimize this a bit for some cases: We can group the functions by their kind, and we can skip comparing functions if we already know that they are not maximal. But since the number of SMFs expected in a class is very (1-3) small, I didn't think those possible improvements are worth the extra complexity.
> 
> Another possible optimization is we could short-circuit this evaluation if we know that a type is not trivially [copyable], since that's the only outcome we really care about, but then the AST is left in a very awkward state.
> 
Thanks, I guess this is fine, I cannot really think of a better way either


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128619/new/

https://reviews.llvm.org/D128619



More information about the cfe-commits mailing list