Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions clang/lib/AST/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,24 +147,27 @@ bool QualType::isConstant(QualType T, const ASTContext &Ctx) {
}

std::optional<QualType::NonConstantStorageReason>
QualType::isNonConstantStorage(const ASTContext &Ctx, bool ExcludeCtor,
bool ExcludeDtor) {
if (!isConstant(Ctx) && !(*this)->isReferenceType())
return NonConstantStorageReason::NonConstNonReferenceType;
if (!Ctx.getLangOpts().CPlusPlus)
return std::nullopt;
if (const CXXRecordDecl *Record =
Ctx.getBaseElementType(*this)->getAsCXXRecordDecl()) {
if (!ExcludeCtor)
return NonConstantStorageReason::NonTrivialCtor;
if (Record->hasMutableFields())
return NonConstantStorageReason::MutableField;
if (!Record->hasTrivialDestructor() && !ExcludeDtor)
return NonConstantStorageReason::NonTrivialDtor;
}
return std::nullopt;
QualType::isNonConstantStorage( const ASTContext &Ctx, bool ExcludeCtor,
bool ExcludeDtor )
{
if ( !isConstant( Ctx ) && !(*this)->isReferenceType() )
return NonConstantStorageReason::NonConstNonReferenceType;
if ( !Ctx.getLangOpts().CPlusPlus )
return std::nullopt;
if ( const CXXRecordDecl *Record =
Ctx.getBaseElementType( *this )->getAsCXXRecordDecl() )
{
if ( !ExcludeCtor )
return NonConstantStorageReason::NonTrivialCtor;
if ( Record->hasMutableFields() )
return NonConstantStorageReason::MutableField;
if ( !Record->hasTrivialDestructor() && !ExcludeDtor )
return NonConstantStorageReason::NonTrivialDtor;
}
return std::nullopt;
}


// C++ [temp.dep.type]p1:
// A type is dependent if it is...
// - an array type constructed from any dependent type or whose
Expand Down