-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Remove now unecessary MSVC trailing objects workaround #7890
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
Conversation
@swift-ci please smoke test |
@swift-ci please smoke test |
1 similar comment
@swift-ci please smoke test |
I'm sorry, I don't understand this change, and looking back at the comment on the LLVM review I don't understand it there either. I see that TrailingObjectsBase isn't actually a templated type, and so it doesn't matter how we get there through TrailingObjects, but isn't it still more correct to use the type we're actually inheriting from? And if it doesn't matter at all, we should still be consistent, possibly standardizing on TrailingObjectsBase instead of TrailingObjects-with-only-one-trailing-type. |
No problem, I was confused too. Basically, the code should be the following in Expr.h: // ...
using TrailingObjects = llvm::TrailingObjects<Derived, Identifier, SourceLoc>;
friend TrailingObjects;
// ...
size_t numTrailingObjects(
typename TrailingObjects::template OverloadToken<Identifier>) const {
return asDerived().getNumArguments();
}
size_t numTrailingObjects(
typename TrailingObjects::template OverloadToken<SourceLoc>) const {
return asDerived().hasArgumentLabelLocs() ? asDerived().getNumArguments()
: 0;
}
// ... but for some reason, MSVC gets horribly confused, and thinks these are the same functions:
The fix (/workaround/hack) is like the following here:
However, then we get errors in the following code in Expr.h: // ...
/// Determine the total size to allocate.
static size_t totalSizeToAlloc(ArrayRef<Identifier> argLabels,
ArrayRef<SourceLoc> argLabelLocs,
bool hasTrailingClosure) {
return TrailingObjects::template totalSizeToAlloc<Identifier, SourceLoc>(
argLabels.size(), argLabelLocs.size());
}
// ...
|
All right, I'll trust you on this. Maybe leave a comment behind to note why we're doing something so strange. :-) |
@swift-ci please smoke test and merge |
1 similar comment
@swift-ci please smoke test and merge |
Unfortunately, MSVC is still buggy, and reports that the functions
and
have identical function parameters, which is obviously incorrect. But apparently this is because we're using TrailingObjects incorrectly here:
https://reviews.llvm.org/D29880