This is an archive of the discontinued LLVM Phabricator instance.

[ASTImporter] Fix import of a typedef that has an attribute
ClosedPublic

Authored by martong on Dec 9 2020, 12:49 PM.

Details

Summary

The import of a typedefs with an attribute uses clang::Decl::setAttrs().
But that needs the ASTContext which we can get only from the
TranslationUnitDecl. But we can get the TUDecl only thourgh the
DeclContext, which is not set by the time of the setAttrs call.

Fix: import the attributes only after the DC is surely imported.
Btw, having the attribute import initiated from GetImportedOrCreateDecl was
fundamentally flawed. Now that is implicitly fixed.

Diff Detail

Event Timeline

martong created this revision.Dec 9 2020, 12:49 PM
martong requested review of this revision.Dec 9 2020, 12:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 9 2020, 12:49 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
shafik added a comment.Dec 9 2020, 3:18 PM

LGTM

clang/unittests/AST/ASTImporterTest.cpp
6097

We can't check the attribute is present?

martong updated this revision to Diff 310869.Dec 10 2020, 5:59 AM
  • Check the attribute in the test as well
martong marked an inline comment as done.Dec 10 2020, 6:00 AM
martong added inline comments.
clang/unittests/AST/ASTImporterTest.cpp
6097

Yes, good point. I've update with some more checks. Thanks for the review!

shafik accepted this revision.Dec 10 2020, 9:06 AM
This revision is now accepted and ready to land.Dec 10 2020, 9:06 AM
This revision was landed with ongoing or failed builds.Dec 14 2020, 9:27 AM
This revision was automatically updated to reflect the committed changes.
martong marked an inline comment as done.

Shafik, thanks for the review!