-
Notifications
You must be signed in to change notification settings - Fork 319
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
[APINotes] Support SwiftImportAs
for C++ structs
#7386
Conversation
I will also submit a part of this patch for review upstream once it is approved. |
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.
Would be good to start flowing this upstream.
if (ImportAsLength > 0) { | ||
info.SwiftImportAs = (std::string(reinterpret_cast<const char *>(data), | ||
ImportAsLength - 1)); | ||
data += ImportAsLength - 1; | ||
} |
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.
What do you think of this pattern?
if (ImportAsLength > 0) { | |
info.SwiftImportAs = (std::string(reinterpret_cast<const char *>(data), | |
ImportAsLength - 1)); | |
data += ImportAsLength - 1; | |
} | |
if (auto BiasedLength = ImportAsLength - 1) { | |
info.SwiftImportAs = (std::string(reinterpret_cast<const char *>(data), | |
BiasedLength)); | |
data += BiasedLength; | |
} |
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.
This underflows unsigned
if ImportAsLength == 0
, we could cast it to signed but I think that would slightly hurt readability.
This allows annotating C++ types as e.g. immortal references using API Notes. This is based on the original patch by Zoe (411d3ab). rdar://114933812
09b5066
to
e751b39
Compare
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.
This is super awesome! Thank you Egor! This will make a lot of people very happy :)
This upstreams a few Clang API Notes attributes that were recently added downstream in the Apple fork (apple#7386).
This upstreams a few Clang API Notes attributes that were recently added downstream in the Apple fork (apple#7386).
This upstreams a few Clang API Notes attributes that were recently added downstream in the Apple fork (apple#7386).
This upstreams a few Clang API Notes attributes that were recently added downstream in the Apple fork (apple/llvm-project#7386).
This allows annotating C++ types as e.g. immortal references using API Notes.
This is based on the original patch by Zoe (411d3ab).
rdar://114933812