-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Clang importer] Don't cache swift_attr source files that have CustomAttrs with arguments #77962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Clang importer] Don't cache swift_attr source files that have CustomAttrs with arguments #77962
Conversation
@swift-ci please smoke test |
lib/ClangImporter/ImportDecl.cpp
Outdated
break; | ||
|
||
for (auto attr : decl->getAttrs()) { | ||
if (auto customAttr = dyn_cast<CustomAttr>(attr)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably want to also capture all subclasses with UNIMPLEMENTED_CLONE
as well. Do we want the implementation of CustomAttr::clone()
to assert if the argument list isn't empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we can do that. Actually, I can avoid the clone here altogether with a different approach that's more similar to how member-attribute macros work.
…Attrs with arguments Since we can't do a proper "deep" clone of expression nodes, cloning such a CustomAttr is necessarily shallow. In such cases, don't cache the swift_attr source files at all, so we get fresh attribute nodes for each such usage.
…bute that won't work
f96c910
to
0c91a34
Compare
@swift-ci please smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a nonblocking inquiry
case DeclAttrKind::CLASS: \ | ||
if (&CLASS##Attr::canClone == &DeclAttribute::canClone) \ | ||
return true; \ | ||
return static_cast<const CLASS##Attr *>(this)->canClone(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, why this manual dynamic dispatch rather than a virtual function? Does DeclAttribute
not have a vtable or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right: there's no vtable, so I don't want to add one.
@swift-ci please test Windows |
@swift-ci please smoke test Linux |
Since we can't do a proper "deep" clone of expression nodes, cloning such a CustomAttr is necessarily shallow. In such cases, don't cache the swift_attr source files at all, so we get fresh attribute nodes for each such usage.