-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[Clang] Fix a regression introduced by #161163. #162612
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1165,14 +1165,30 @@ static bool EvaluateUnaryTypeTrait(Sema &Self, TypeTrait UTT, | |
const CXXDestructorDecl *Dtor = RD->getDestructor(); | ||
if (UnqualT->isAggregateType() && (!Dtor || !Dtor->isUserProvided())) | ||
return true; | ||
if (RD->hasTrivialDestructor() && (!Dtor || !Dtor->isDeleted())) { | ||
for (CXXConstructorDecl *Ctr : RD->ctors()) { | ||
if (Ctr->isIneligibleOrNotSelected() || Ctr->isDeleted()) | ||
continue; | ||
if (Ctr->isTrivial()) | ||
return true; | ||
} | ||
if (!(RD->hasTrivialDestructor() && (!Dtor || !Dtor->isDeleted()))) | ||
return false; | ||
if (RD->hasTrivialDefaultConstructor()) | ||
return true; | ||
bool FoundCopyCtr = false; | ||
bool FoundMoveCtr = false; | ||
bool FoundDefaultCtr = false; | ||
for (CXXConstructorDecl *Ctr : RD->ctors()) { | ||
if (Ctr->isIneligibleOrNotSelected() || Ctr->isDeleted()) | ||
continue; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test fails now because short-circuiting here occurs before |
||
if (Ctr->isTrivial()) | ||
return true; | ||
FoundCopyCtr = Ctr->isCopyConstructor(); | ||
FoundMoveCtr = Ctr->isMoveConstructor(); | ||
FoundDefaultCtr = Ctr->isDefaultConstructor(); | ||
} | ||
if (!FoundDefaultCtr && RD->hasTrivialDefaultConstructor()) | ||
return true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is never reached because |
||
if (!FoundCopyCtr && RD->hasTrivialCopyConstructor() && | ||
!RD->defaultedCopyConstructorIsDeleted()) | ||
return true; | ||
if (!FoundMoveCtr && RD->hasTrivialMoveConstructor() && | ||
!RD->defaultedMoveConstructorIsDeleted()) | ||
return true; | ||
return false; | ||
} | ||
case UTT_IsIntangibleType: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2066,7 +2066,27 @@ class UserProvidedConstructor { | |
UserProvidedConstructor(const UserProvidedConstructor&) = delete; | ||
UserProvidedConstructor& operator=(const UserProvidedConstructor&) = delete; | ||
}; | ||
struct Ctr { | ||
Ctr(); | ||
}; | ||
struct Ctr2 { | ||
Ctr2(); | ||
private: | ||
NoEligibleTrivialContructor inner; | ||
}; | ||
|
||
struct NonCopyable{ | ||
NonCopyable() = default; | ||
NonCopyable(const NonCopyable&) = delete; | ||
}; | ||
|
||
class C { | ||
NonCopyable nc; | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be good to add a note that the classes should not be used here in any way causing declarations of the implicit methods to be instantiated (or whatever the correct word is). |
||
|
||
static_assert(__builtin_is_implicit_lifetime(Ctr)); | ||
static_assert(__builtin_is_implicit_lifetime(C)); | ||
static_assert(!__builtin_is_implicit_lifetime(NoEligibleTrivialContructor)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
static_assert(__builtin_is_implicit_lifetime(NonAggregate)); | ||
static_assert(!__builtin_is_implicit_lifetime(DataMemberInitializer)); | ||
static_assert(!__builtin_is_implicit_lifetime(UserProvidedConstructor)); | ||
|
@@ -2076,7 +2096,7 @@ template <typename T> | |
class Tpl { | ||
Tpl() requires false = default ; | ||
}; | ||
static_assert(!__builtin_is_implicit_lifetime(Tpl<int>)); | ||
static_assert(__builtin_is_implicit_lifetime(Tpl<int>)); | ||
|
||
#endif | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UTT_HasTrivialDefaultConstructor
handler checksRD->hasTrivialDefaultConstructor() && !RD->hasNonTrivialDefaultConstructor()
for some reason. Not sure if this is really needed.