Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

[upstream-with-swift] Add workaround for MSVC bug #43

Closed
wants to merge 1 commit into from
Closed

[upstream-with-swift] Add workaround for MSVC bug #43

wants to merge 1 commit into from

Conversation

hughbe
Copy link
Collaborator

@hughbe hughbe commented Jan 25, 2017

See swiftlang/swift#3759 (comment)

The problem is that MSVC doesn't recognise the following syntax, reporting multiple errors here:

  size_t numTrailingObjects(
      typename TrailingObjects::template OverloadToken<SourceLoc>) const {
    return asDerived().hasArgumentLabelLocs()
             ? asDerived().getNumArguments()
             : 0;
  }

For some reason, MSVC ignores the fact that we gave friend access to llvm::TrailingObjects here.

Note that the Swift source code also has to be modified, as this is not enough. This is the new source code, that fully compiles after this change!

  // Work around MSVC bug: can't infer llvm::trailing_objects_internal, even though we granted friend access to it
	size_t numTrailingObjects(
		llvm::trailing_objects_internal::TrailingObjectsBase::OverloadToken<Identifier>) const {
		typename TrailingObjects::template OverloadToken<Identifier>) const {
    return asDerived().getNumArguments();
  }

@jrose-apple
Copy link
Contributor

Again, can we get this into real upstream LLVM instead?

@hughbe
Copy link
Collaborator Author

hughbe commented Jan 25, 2017

Oh, so that's what you meant by upstream :(
My bad!!

@hughbe
Copy link
Collaborator Author

hughbe commented Jan 25, 2017

For upstream, do you think we should remove the #ifdef and just change from private to protected

@jrose-apple
Copy link
Contributor

Ah, sorry for not being clear!

I'm not sure how I feel about that. protected everywhere isn't really harmful, but it does still inject extra members into the scope. Probably someone in the LLVM community will have a stronger opinion.

@hughbe
Copy link
Collaborator Author

hughbe commented Jan 26, 2017

Ah, sorry for not being clear!

No problem, there are two upstreams :D

I've opened https://reviews.llvm.org/D29181 for discussion on this - first real submission to LLVM so I hope I've correctly done it :)

@hughbe
Copy link
Collaborator Author

hughbe commented Feb 8, 2017

Looks like no one has looked at https://reviews.llvm.org/D29181, have I correctly published it?

@jrose-apple
Copy link
Contributor

That's correct enough. I'll poke the owner of TrailingObjects to hopefully get some movement.

@hughbe
Copy link
Collaborator Author

hughbe commented Feb 8, 2017

Thanks Jordan, appreciate it!

See swiftlang/swift#3759 (comment)

The problem is that MSVC doesn't recognise the following syntax, reporting multiple errors [here](https://github.com/apple/swift/blob/master/include/swift/AST/Expr.h#L661):
```
  size_t numTrailingObjects(
      typename TrailingObjects::template OverloadToken<SourceLoc>) const {
    return asDerived().hasArgumentLabelLocs()
             ? asDerived().getNumArguments()
             : 0;
  }
```

For some reason, MSVC ignores the fact that we gave friend access to `llvm::TrailingObjects` [here]().

Note that the Swift source code also has to be modified, as this is not enough. This is the new source code, that fully compiles after this change!
```
  // Work around MSVC bug: can't infer llvm::trailing_objects_internal, even though we granted friend access to it
	size_t numTrailingObjects(
		llvm::trailing_objects_internal::TrailingObjectsBase::OverloadToken<Identifier>) const {
		typename TrailingObjects::template OverloadToken<Identifier>) const {
    return asDerived().getNumArguments();
  }
```
@hughbe hughbe closed this Mar 3, 2017
@hughbe
Copy link
Collaborator Author

hughbe commented Mar 3, 2017

Closed this - I'll also handle updating swift, when I get the time

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants