-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Give OptionSet an initializer_list constructor #32447
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
Give OptionSet an initializer_list constructor #32447
Conversation
@swift-ci Please test |
Build failed |
@swift-ci Please test OS X |
af6b58f
to
4528dbf
Compare
@swift-ci Please test |
Build failed |
Build failed |
@@ -58,6 +59,10 @@ class OptionSet { | |||
/// Create an option set with only the given option set. | |||
constexpr OptionSet(Flags flag) : Storage(static_cast<StorageType>(flag)) {} | |||
|
|||
/// Create an option set containing the given options. | |||
constexpr OptionSet(std::initializer_list<Flags> flags) |
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 constructor cannot be constexpr
unless combineFlags
is constexpr
.
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.
Huh, of course. Done.
I'm surprised the compiler didn't complain about this?
lib/Index/Index.cpp
Outdated
ImportFilter |= ModuleDecl::ImportFilterKind::Public; | ||
ImportFilter |= ModuleDecl::ImportFilterKind::Private; | ||
ImportFilter |= ModuleDecl::ImportFilterKind::ImplementationOnly; | ||
ModuleDecl::ImportFilter ImportFilter = { |
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.
constexpr
here.
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.
Done.
ModuleDecl::ImportFilter ImportFilter; | ||
ImportFilter |= ModuleDecl::ImportFilterKind::Public; | ||
ImportFilter |= ModuleDecl::ImportFilterKind::Private; | ||
ModuleDecl::ImportFilter ImportFilter = { |
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.
And here
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 doesn't work because ImportFilter
is modified below.
4528dbf
to
91674cb
Compare
This makes it easier to specify OptionSet arguments. Also modify appropriate uses of ModuleDecl::ImportFilter to take advantage of the new constructor.
91674cb
to
d806ba5
Compare
@swift-ci Please test |
Build failed |
Build failed |
⛵ |
This makes it easier to specify
OptionSet
arguments.Also modify appropriate uses of
ModuleDecl::ImportFilter
to take advantage of the new constructor.