This is an archive of the discontinued LLVM Phabricator instance.

Clang crashed while checking for deletion of copy and move ctors
ClosedPublic

Authored by oontvoo on Jul 6 2020, 3:19 PM.

Details

Reviewers
jyknight
rsmith
Summary

Repro:
template <class> class __attribute__((trivial_abi)) a { a(a &&); };

Crash:

@     0x559d129463fc  clang::CXXRecordDecl::defaultedCopyConstructorIsDeleted()
 @     0x559d1288d3e5  clang::Sema::checkIllFormedTrivialABIStruct()::$_7::operator()()
 @     0x559d12884c34  clang::Sema::checkIllFormedTrivialABIStruct()
 @     0x559d1288412e  clang::Sema::CheckCompletedCXXClass()
 @     0x559d1288d843  clang::Sema::ActOnFinishCXXMemberSpecification()
 @     0x559d12020109  clang::Parser::ParseCXXMemberSpecification()
 @     0x559d1201e80c  clang::Parser::ParseClassSpecifier()
 @     0x559d1204e807  clang::Parser::ParseDeclarationSpecifiers()
 @     0x559d120e9aa9  clang::Parser::ParseSingleDeclarationAfterTemplate()
 @     0x559d120e8f21  clang::Parser::ParseTemplateDeclarationOrSpecialization()
 @     0x559d120e8886  clang::Parser::ParseDeclarationStartingWithTemplate()
 @     0x559d1204a1d4  clang::Parser::ParseDeclaration()
 @     0x559d12004b1d  clang::Parser::ParseExternalDeclaration()
 @     0x559d12017689  clang::Parser::ParseInnerNamespace()
 @     0x559d12017024  clang::Parser::ParseNamespace()
 @     0x559d1204a29b  clang::Parser::ParseDeclaration()
 @     0x559d12004c74  clang::Parser::ParseExternalDeclaration()

Diff Detail

Event Timeline

oontvoo created this revision.Jul 6 2020, 3:19 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2020, 3:19 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
oontvoo edited the summary of this revision. (Show Details)Jul 6 2020, 4:09 PM
oontvoo edited the summary of this revision. (Show Details)
oontvoo updated this revision to Diff 275866.Jul 6 2020, 5:11 PM

add test

oontvoo updated this revision to Diff 275885.Jul 6 2020, 7:02 PM

Dont skip checking even for templated type

oontvoo updated this revision to Diff 275895.Jul 6 2020, 8:24 PM

Add more tests

oontvoo updated this revision to Diff 275898.Jul 6 2020, 8:48 PM

updated diff

oontvoo updated this revision to Diff 275899.Jul 6 2020, 8:55 PM

updated diff

rsmith added a subscriber: rsmith.Jul 6 2020, 10:33 PM
rsmith added inline comments.
clang/lib/Sema/SemaDeclCXX.cpp
9733

This is not the right fallback answer if the class is a dependent type -- we don't yet know if there's a non-deleted copy or move constructor if one might be implicitly declared, so we should conservatively assume that there might be one. It'd probably be easiest to return true from this function at the very start if the type is dependent (because we don't know if there's a non-deleted copy or move constructor).

clang/test/SemaObjCXX/attr-trivial-abi.mm
60–63

We should not diagnose this, because instantiations of this template might have non-deleted copy or move constructors. (We don't know yet when parsing the template definition.)

oontvoo updated this revision to Diff 276076.Jul 7 2020, 8:18 AM
oontvoo marked 2 inline comments as done.

prevent diagnostics for dependent types

oontvoo updated this revision to Diff 276084.Jul 7 2020, 8:30 AM

one more test

oontvoo retitled this revision from [WIP] Clang crashed while checking for deletion of copy and move ctors to Clang crashed while checking for deletion of copy and move ctors.Jul 7 2020, 10:28 AM
oontvoo added reviewers: jyknight, rsmith.
rsmith accepted this revision.Jul 7 2020, 11:27 AM
This revision is now accepted and ready to land.Jul 7 2020, 11:27 AM
oontvoo closed this revision.Jul 7 2020, 12:28 PM