-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[Diagnostics] Add -no-warning-as-error to except a specific warning from being treated as an error #74466
Open
DmT021
wants to merge
2
commits into
swiftlang:main
Choose a base branch
from
DmT021:wp/no-warning-as-error
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[Diagnostics] Add -no-warning-as-error to except a specific warning from being treated as an error #74466
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| //===--- DefineDiagnosticGroupsMacros.def -----------------------*- C++ -*-===// | ||
| // | ||
| // This source file is part of the Swift.org open source project | ||
| // | ||
| // Copyright (c) 2024 Apple Inc. and the Swift project authors | ||
| // Licensed under Apache License v2.0 with Runtime Library Exception | ||
| // | ||
| // See https://swift.org/LICENSE.txt for license information | ||
| // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // This file defines macros defining diagnostic groups. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // Define macros | ||
| #if defined(DEFINE_DIAGNOSTIC_GROUPS_MACROS) && \ | ||
| !defined(UNDEFINE_DIAGNOSTIC_GROUPS_MACROS) | ||
|
|
||
| #undef DEFINE_DIAGNOSTIC_GROUPS_MACROS | ||
|
|
||
| #if !(defined(GROUP) || defined(GROUP_LINK)) | ||
| #error No reqired macros defined. Define at least one of the following macros: GROUP(Name, DocsFile), GROUP_LINK(Parent, Child) | ||
| #endif | ||
|
|
||
| // GROUP macro: | ||
| // Declares a diagnostic group. | ||
| // Parameters: | ||
| // Name - group name as it appears in DiagGroupID enum and DiagGroupInfo.name | ||
| // DocsFile - file with a human readable description for the group located in | ||
| // userdocs/diagnostic_groups | ||
| #ifndef GROUP | ||
| #define GROUP(Name, DocsFile) | ||
| #endif | ||
|
|
||
| // GROUP_LINK macro: | ||
| // Establishes an edge in the diagnostic group graph between | ||
| // a supergroup(Parent) and its subgroup(Child). | ||
| // Parameters: | ||
| // Parent - parent group name | ||
| // Child - child group name | ||
| #ifndef GROUP_LINK | ||
| #define GROUP_LINK(Parent, Child) | ||
| #endif | ||
|
|
||
| // Undefine macros | ||
| #elif defined(UNDEFINE_DIAGNOSTIC_GROUPS_MACROS) && \ | ||
| !defined(DEFINE_DIAGNOSTIC_GROUPS_MACROS) | ||
|
|
||
| #undef UNDEFINE_DIAGNOSTIC_GROUPS_MACROS | ||
|
|
||
| #ifdef GROUP | ||
| #undef GROUP | ||
| #else | ||
| #error Trying to undefine the diagnostic groups macros, but GROUP macro wasn't defined | ||
| #endif | ||
|
|
||
| #ifdef GROUP_LINK | ||
| #undef GROUP_LINK | ||
| #else | ||
| #error Trying to undefine the diagnostic groups macros, but GROUP_LINK macro wasn't defined | ||
| #endif | ||
|
|
||
| #else | ||
| #error Invalid DefineDiagnosticGroupsMacros.h inclusion | ||
| #endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| //===--- DiagnosticGroups.def - Diagnostic Groups ---------------*- C++ -*-===// | ||
| // | ||
| // This source file is part of the Swift.org open source project | ||
| // | ||
| // Copyright (c) 2024 Apple Inc. and the Swift project authors | ||
| // Licensed under Apache License v2.0 with Runtime Library Exception | ||
| // | ||
| // See https://swift.org/LICENSE.txt for license information | ||
| // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // This file defines diagnostic groups and links between them. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #define DEFINE_DIAGNOSTIC_GROUPS_MACROS | ||
| #include "swift/AST/DefineDiagnosticGroupsMacros.h" | ||
|
|
||
| // GROUP(Name, DocsFile) | ||
| // GROUP_LINK(Parent, Child) | ||
|
|
||
| GROUP(no_group, "") | ||
|
|
||
| GROUP(deprecated, "deprecated.md") | ||
| GROUP_LINK(deprecated, availability_deprecated) | ||
|
|
||
| GROUP(availability_deprecated, "availability_deprecated.md") | ||
|
|
||
| GROUP(unknown_warning_group, "unknown_warning_group.md") | ||
|
|
||
| #define UNDEFINE_DIAGNOSTIC_GROUPS_MACROS | ||
| #include "swift/AST/DefineDiagnosticGroupsMacros.h" | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| //===--- DiagnosticGroups.h - Diagnostic Groups -----------------*- C++ -*-===// | ||
| // | ||
| // This source file is part of the Swift.org open source project | ||
| // | ||
| // Copyright (c) 2014 - 2024 Apple Inc. and the Swift project authors | ||
| // Licensed under Apache License v2.0 with Runtime Library Exception | ||
| // | ||
| // See https://swift.org/LICENSE.txt for license information | ||
| // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // This file defines the diagnostic groups enumaration, group graph | ||
| // and auxilary functions. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef SWIFT_DIAGNOSTICGROUPS_H | ||
| #define SWIFT_DIAGNOSTICGROUPS_H | ||
|
|
||
| #include "swift/AST/DiagnosticList.h" | ||
| #include "llvm/ADT/ArrayRef.h" | ||
| #include <array> | ||
| #include <string_view> | ||
| #include <unordered_map> | ||
|
|
||
| namespace swift { | ||
|
|
||
| enum class DiagGroupID : uint16_t { | ||
| #define GROUP(Name, Version) Name, | ||
| #include "swift/AST/DiagnosticGroups.def" | ||
| }; | ||
|
|
||
| constexpr const auto DiagGroupsCount = [] { | ||
| size_t count = 0; | ||
| #define GROUP(Name, Version) count++; | ||
| #include "DiagnosticGroups.def" | ||
| return count; | ||
| }(); | ||
|
|
||
| struct DiagGroupInfo { | ||
| DiagGroupID id; | ||
| std::string_view name; | ||
DmT021 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| std::string_view version; | ||
| llvm::ArrayRef<DiagGroupID> supergroups; | ||
| llvm::ArrayRef<DiagGroupID> subgroups; | ||
| llvm::ArrayRef<DiagID> diagnostics; | ||
|
|
||
| void traverseDepthFirst( | ||
| llvm::function_ref<void(const DiagGroupInfo &)> func) const; | ||
| }; | ||
|
|
||
| extern const std::array<DiagGroupInfo, DiagGroupsCount> diagnosticGroupsInfo; | ||
| const DiagGroupInfo &getDiagGroupInfoByID(DiagGroupID id); | ||
| std::optional<DiagGroupID> getDiagGroupIDByName(std::string_view name); | ||
|
|
||
| } // end namespace swift | ||
|
|
||
| #endif /* SWIFT_DIAGNOSTICGROUPS_H */ | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| //===--- DiagnosticList.h - Diagnostic Definitions --------------*- C++ -*-===// | ||
| // | ||
| // This source file is part of the Swift.org open source project | ||
| // | ||
| // Copyright (c) 2014 - 2024 Apple Inc. and the Swift project authors | ||
| // Licensed under Apache License v2.0 with Runtime Library Exception | ||
| // | ||
| // See https://swift.org/LICENSE.txt for license information | ||
| // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // This file defines all of the diagnostics emitted by Swift. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef SWIFT_DIAGNOSTICLIST_H | ||
| #define SWIFT_DIAGNOSTICLIST_H | ||
|
|
||
| #include <cstdint> | ||
|
|
||
| namespace swift { | ||
|
|
||
| /// Enumeration describing all of possible diagnostics. | ||
| /// | ||
| /// Each of the diagnostics described in Diagnostics.def has an entry in | ||
| /// this enumeration type that uniquely identifies it. | ||
| enum class DiagID : uint32_t { | ||
| #define DIAG(KIND, ID, Group, Options, Text, Signature) ID, | ||
| #include "swift/AST/DiagnosticsAll.def" | ||
| }; | ||
| static_assert(static_cast<uint32_t>(swift::DiagID::invalid_diagnostic) == 0, | ||
| "0 is not the invalid diagnostic ID"); | ||
|
|
||
| enum class FixItID : uint32_t { | ||
| #define DIAG(KIND, ID, Group, Options, Text, Signature) | ||
| #define FIXIT(ID, Text, Signature) ID, | ||
| #include "swift/AST/DiagnosticsAll.def" | ||
| }; | ||
|
|
||
| } // end namespace swift | ||
|
|
||
| #endif /* SWIFT_DIAGNOSTICLIST_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It's not critical now, but at some point we'd want a big comment here documenting what it means to define a new group.