This is an archive of the discontinued LLVM Phabricator instance.

[clang] Exclude invalid destructors from lookups.
ClosedPublic

Authored by adamcz on Aug 26 2020, 7:46 AM.

Details

Summary

This fixes a crash when declaring a destructor with a wrong name, then
writing result to pch file and loading it again. The PCH storage uses
DeclarationNameKey as key and it is the same key for both the invalid
destructor and the implicit one that was created because the other one
was invalid. When querying for the Foo::~Foo we end up getting
Foo::~Bar, which is then rejected and we end up with nullptr in
CXXRecordDecl::GetDestructor().

Fixes https://bugs.llvm.org/show_bug.cgi?id=47270

Diff Detail

Unit TestsFailed

Event Timeline

adamcz created this revision.Aug 26 2020, 7:46 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 26 2020, 7:46 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
adamcz requested review of this revision.Aug 26 2020, 7:46 AM
sammccall accepted this revision.Aug 26 2020, 7:57 AM
sammccall added a subscriber: sammccall.
sammccall added inline comments.
clang/lib/AST/DeclBase.cpp
1489

split into separate block, add a comment why

clang/test/PCH/cxx-invalid-destructor.cpp
3

nit: -fno-validate-pch shouldn't be needed IIUC

clang/test/PCH/cxx-invalid-destructor.h
7

nit: we can eliminate Bar I think?

This revision is now accepted and ready to land.Aug 26 2020, 7:57 AM
adamcz updated this revision to Diff 287983.Aug 26 2020, 8:18 AM
adamcz marked 2 inline comments as done.

addressed review comments

clang/test/PCH/cxx-invalid-destructor.cpp
3

We need this, otherwise the PCH file is rejected for containing errors.

This revision was landed with ongoing or failed builds.Aug 26 2020, 10:36 AM
This revision was automatically updated to reflect the committed changes.