-
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 1 commit
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 |
---|---|---|
|
@@ -1167,16 +1167,22 @@ static bool EvaluateUnaryTypeTrait(Sema &Self, TypeTrait UTT, | |
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()) { | ||
FoundCopyCtr = Ctr->isCopyConstructor(); | ||
FoundMoveCtr = Ctr->isMoveConstructor(); | ||
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; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2075,7 +2075,17 @@ struct Ctr2 { | |
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)); | ||
|
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.