-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Resolve a Layering Violation in libBasic #61014
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
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.
Thanks for cleaning up the dependency issue.
include/swift/Parse/ParseVersion.h
Outdated
@@ -0,0 +1,45 @@ | |||
//===--- VersionParser.h - Parser Swift Version Numbers ---------*- C++ -*-===// |
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 doesn't match the name of the file. VersionParser.h
seems more in line with the rest of the tree.
Version getCurrentCompilerVersion(); | ||
} // namespace version | ||
|
||
class VersionParser final { |
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.
Is there a reason to make this a class and add static
methods rather than a namespace and free functions for parseCompilerVersionString
and parseVersionString
?
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.
I need to friend Version so I can poke at the component vector.
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.
Ah, I see. That probably deserves a comment.
@swift-ci please smoke test |
376fef9
to
3c9645f
Compare
@swift-ci 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.
friend
s are gross, but meh, I'll allow it.
It looks like you should be able to parse out the numbers and then use the Version
constructor to emit the version once you've computed everything instead of needing to manipulate the components list directly. Then we can drop the friend.
I merged the other patch to get clean builds.
If you want to, feel free to remove the circular link edge. If not, I can do it later.
https://github.com/apple/swift/blob/4b7db51477d08f0c20d57d11a9e7b2b2f7ae281f/lib/Basic/CMakeLists.txt#L101-L103
Basic should not be allowed to link Parse, yet it was doing so to allow Version to provide a constructor that would conveniently parse a StringRef. This entrypoint also emitted diagnostics, so it pulled in libAST. Sink the version parser entrypoint down into Parse where it belongs and point all the clients to the right place.
This reverts commit 9010813.
3c9645f
to
a71b970
Compare
@swift-ci 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.
I like @etcwilde's suggestion for using the ctor for Version
rather than friend
and then making the functions free functions rather than part of an empty class, but that seems less important than the circular dependency issues.
This is set on a per-file basis and was not forwarded when swiftlang#61014 was integrated. This is a short-term fix for this issue. I don't see a reason this version number should be applied to individual files instead of being passed as an argument to every translation unit. rdar://102731783
Basic should not be allowed to link Parse, yet it was doing so to allow Version to provide a constructor that would conveniently parse a StringRef. This entrypoint also emitted diagnostics, so it pulled in libAST.
Sink the version parser entrypoint down into Parse where it belongs and point all the clients to the right place.