|
2 | 2 | //
|
3 | 3 | // This source file is part of the Swift.org open source project
|
4 | 4 | //
|
5 |
| -// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors |
| 5 | +// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors |
6 | 6 | // Licensed under Apache License v2.0 with Runtime Library Exception
|
7 | 7 | //
|
8 | 8 | // See https://swift.org/LICENSE.txt for license information
|
@@ -750,31 +750,32 @@ static bool ParseEnabledFeatureArgs(LangOptions &Opts, ArgList &Args,
|
750 | 750 | OPT_enable_upcoming_feature, OPT_disable_upcoming_feature)) {
|
751 | 751 | auto &option = A->getOption();
|
752 | 752 | StringRef value = A->getValue();
|
753 |
| - bool enableUpcoming = option.matches(OPT_enable_upcoming_feature); |
754 |
| - bool isUpcomingFlag = |
755 |
| - enableUpcoming || option.matches(OPT_disable_upcoming_feature); |
756 |
| - bool enableFeature = |
757 |
| - enableUpcoming || option.matches(OPT_enable_experimental_feature); |
| 753 | + bool isEnableUpcomingFeatureFlag = |
| 754 | + option.matches(OPT_enable_upcoming_feature); |
| 755 | + bool isUpcomingFeatureFlag = isEnableUpcomingFeatureFlag || |
| 756 | + option.matches(OPT_disable_upcoming_feature); |
| 757 | + bool isEnableFeatureFlag = isEnableUpcomingFeatureFlag || |
| 758 | + option.matches(OPT_enable_experimental_feature); |
758 | 759 |
|
759 | 760 | // Collect some special case pseudo-features which should be processed
|
760 | 761 | // separately.
|
761 | 762 | if (value.starts_with("StrictConcurrency") ||
|
762 | 763 | value.starts_with("AvailabilityMacro=")) {
|
763 |
| - if (enableFeature) |
| 764 | + if (isEnableFeatureFlag) |
764 | 765 | psuedoFeatures.push_back(value);
|
765 | 766 | continue;
|
766 | 767 | }
|
767 | 768 |
|
768 | 769 | auto feature = getUpcomingFeature(value);
|
769 | 770 | if (feature) {
|
770 | 771 | // Diagnose upcoming features enabled with -enable-experimental-feature.
|
771 |
| - if (!isUpcomingFlag) |
| 772 | + if (!isUpcomingFeatureFlag) |
772 | 773 | Diags.diagnose(SourceLoc(), diag::feature_not_experimental, value,
|
773 |
| - enableFeature); |
| 774 | + isEnableFeatureFlag); |
774 | 775 | } else {
|
775 | 776 | // If -enable-upcoming-feature was used and an upcoming feature was not
|
776 | 777 | // found, diagnose and continue.
|
777 |
| - if (isUpcomingFlag) { |
| 778 | + if (isUpcomingFeatureFlag) { |
778 | 779 | Diags.diagnose(SourceLoc(), diag::unrecognized_feature, value,
|
779 | 780 | /*upcoming=*/true);
|
780 | 781 | continue;
|
@@ -815,7 +816,7 @@ static bool ParseEnabledFeatureArgs(LangOptions &Opts, ArgList &Args,
|
815 | 816 | }
|
816 | 817 |
|
817 | 818 | // Enable the feature if requested.
|
818 |
| - if (enableFeature) |
| 819 | + if (isEnableFeatureFlag) |
819 | 820 | Opts.enableFeature(*feature);
|
820 | 821 | }
|
821 | 822 |
|
|
0 commit comments