================
@@ -878,52 +939,16 @@ static bool EvaluateUnaryTypeTrait(Sema &Self, TypeTrait
UTT,
!RD->hasNonTrivialCopyAssignment();
return false;
case UTT_IsDestructible:
+ return clang::GetDestructorFormat(Self, C, KeyLoc, T) !=
+ DestructorFormat::NotAvailable;
case UTT_IsTriviallyDestructible:
- case UTT_IsNothrowDestructible:
- // C++14 [meta.unary.prop]:
- // For reference types, is_destructible<T>::value is true.
- if (T->isReferenceType())
- return true;
-
- // Objective-C++ ARC: autorelease types don't require destruction.
- if (T->isObjCLifetimeType() &&
- T.getObjCLifetime() == Qualifiers::OCL_Autoreleasing)
- return true;
-
- // C++14 [meta.unary.prop]:
- // For incomplete types and function types, is_destructible<T>::value is
- // false.
- if (T->isIncompleteType() || T->isFunctionType())
- return false;
-
- // A type that requires destruction (via a non-trivial destructor or ARC
- // lifetime semantics) is not trivially-destructible.
- if (UTT == UTT_IsTriviallyDestructible && T.isDestructedType())
- return false;
-
- // C++14 [meta.unary.prop]:
- // For object types and given U equal to remove_all_extents_t<T>, if the
- // expression std::declval<U&>().~U() is well-formed when treated as an
- // unevaluated operand (Clause 5), then is_destructible<T>::value is true
- if (auto *RD = C.getBaseElementType(T)->getAsCXXRecordDecl()) {
- CXXDestructorDecl *Destructor = Self.LookupDestructor(RD);
- if (!Destructor)
- return false;
- // C++14 [dcl.fct.def.delete]p2:
- // A program that refers to a deleted function implicitly or
- // explicitly, other than to declare it, is ill-formed.
- if (Destructor->isDeleted())
- return false;
- if (C.getLangOpts().AccessControl && Destructor->getAccess() !=
AS_public)
- return false;
- if (UTT == UTT_IsNothrowDestructible) {
- auto *CPT = Destructor->getType()->castAs<FunctionProtoType>();
- CPT = Self.ResolveExceptionSpec(KeyLoc, CPT);
- if (!CPT || !CPT->isNothrow())
- return false;
- }
- }
- return true;
+ return clang::GetDestructorFormat(Self, C, KeyLoc, T) ==
+ DestructorFormat::Trivial;
+ case UTT_IsNothrowDestructible: {
+ auto Format = clang::GetDestructorFormat(Self, C, KeyLoc, T);
+ return Format != DestructorFormat::NotAvailable &&
+ clang::IsDestructorNoThrow(Self, C, KeyLoc, T);
+ }
----------------
cor3ntin wrote:
That refactor is doing lookup twice which I think we should avoid - If we are
going that direction we could extract the destructor and pass it to
IsDestructorNoThrow
https://github.com/llvm/llvm-project/pull/238456
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits