-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[clang] Implement __builtin_is_implicit_lifetime()
#101807
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
Changes from 2 commits
9c4e7cc
ad0abb5
49de16a
5dbfdf5
5221a00
318cc3b
a8acfcd
9951de4
5dfa7c1
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 |
---|---|---|
|
@@ -5039,6 +5039,7 @@ static bool CheckUnaryTypeTraitTypeCompleteness(Sema &S, TypeTrait UTT, | |
|
||
// LWG3823: T shall be an array type, a complete type, or cv void. | ||
case UTT_IsAggregate: | ||
case UTT_IsImplicitLifetime: | ||
if (ArgTy->isArrayType() || ArgTy->isVoidType()) | ||
return true; | ||
|
||
|
@@ -5637,6 +5638,27 @@ static bool EvaluateUnaryTypeTrait(Sema &Self, TypeTrait UTT, | |
return false; | ||
case UTT_IsTriviallyEqualityComparable: | ||
return isTriviallyEqualityComparableType(Self, T, KeyLoc); | ||
case UTT_IsImplicitLifetime: { | ||
DiagnoseVLAInCXXTypeTrait(Self, TInfo, | ||
tok::kw___builtin_is_implicit_lifetime); | ||
QualType UnqualT = T->getCanonicalTypeUnqualified(); | ||
Endilll marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (UnqualT->isScalarType()) | ||
AaronBallman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return true; | ||
if (UnqualT->isArrayType()) | ||
return true; | ||
|
||
const CXXRecordDecl *RD = UnqualT->getAsCXXRecordDecl(); | ||
Endilll marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (!RD) | ||
return false; | ||
if (UnqualT->isAggregateType()) | ||
if (!RD->getDestructor()->isUserProvided()) | ||
return true; | ||
if (RD->hasTrivialDestructor()) | ||
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. You also need to check that it's not deleted too. Currently the first two assertions fail here: struct X { ~X() = delete; };
struct Y { X x; ~Y() = default; };
struct Z { X x; };
static_assert(!__builtin_is_implicit_lifetime(X));
static_assert(!__builtin_is_implicit_lifetime(Y));
static_assert( __builtin_is_implicit_lifetime(Z)); 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. All three types in your examples are implicit lifetime class types, because they are aggregates and does not have a user-provided destructor. 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.
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.
I'm sorry, but the only thing I see there are user-declared destructors, not constructors. |
||
if (RD->hasTrivialDefaultConstructor() || | ||
RD->hasTrivialCopyConstructor() || RD->hasTrivialMoveConstructor()) | ||
return true; | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.