This is an archive of the discontinued LLVM Phabricator instance.

[Sema] Add implicit members even for invalid CXXRecordDecls
ClosedPublic

Authored by ilya-biryukov on Feb 1 2018, 11:58 AM.

Details

Summary

It should be safe, since other code paths are already generating
implicit members even in invalid CXXRecordDecls (e.g. lookup).

If we don't generate implicit members on CXXRecordDecl's completion,
they will be generated by next lookup of constructors. This causes a
crash when the following conditions are met:

  • a CXXRecordDecl is invalid,
  • it is provided via ExternalASTSource (e.g. from PCH),
  • it has inherited constructors (they create ShadowDecls),
  • lookup of its constructors was not run before ASTWriter serialized it.

This may require the ShadowDecls created for inherited constructors to
be removed from the class, but that's no longer possible since class is
provided by ExternalASTSource.

See provided lit test for an example.

Diff Detail

Repository
rC Clang

Event Timeline

ilya-biryukov created this revision.Feb 1 2018, 11:58 AM
ilya-biryukov edited the summary of this revision. (Show Details)Feb 1 2018, 11:59 AM
ilya-biryukov edited the summary of this revision. (Show Details)

The following assertion from DeclContext::removeDecl was failing before:

assert((D->NextInContextAndBits.getPointer() || D == LastDecl) &&
       "decl is not in decls list");
This revision is now accepted and ready to land.Feb 1 2018, 12:43 PM
This revision was automatically updated to reflect the committed changes.