|
2 | 2 | //
|
3 | 3 | // This source file is part of the Swift.org open source project
|
4 | 4 | //
|
5 |
| -// Copyright (c) 2014 - 2017 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
|
|
15 | 15 | //
|
16 | 16 | //===----------------------------------------------------------------------===//
|
17 | 17 |
|
18 |
| -#include "swift/AST/DiagnosticEngine.h" |
19 |
| -#include "swift/AST/DiagnosticsModuleDiffer.h" |
20 | 18 | #include "swift/APIDigester/ModuleDiagsConsumer.h"
|
| 19 | +#include "swift/AST/DiagnosticEngine.h" |
| 20 | +#include "swift/AST/DiagnosticList.h" |
21 | 21 | #include "swift/Basic/Assertions.h"
|
22 | 22 |
|
23 | 23 | using namespace swift;
|
24 | 24 |
|
25 |
| -namespace { |
26 |
| -// Reproduce the DiagIDs, as we want both the size and access to the raw ids |
27 |
| -// themselves. |
28 |
| -enum LocalDiagID : uint32_t { |
29 |
| -#define DIAG(KIND, ID, Group, Options, Text, Signature) ID, |
30 |
| -#include "swift/AST/DiagnosticsAll.def" |
31 |
| - NumDiags |
32 |
| -}; |
33 |
| - |
34 |
| -static StringRef getCategoryName(uint32_t ID) { |
| 25 | +static StringRef getCategoryName(DiagID ID) { |
35 | 26 | switch(ID) {
|
36 |
| - case LocalDiagID::removed_decl: |
| 27 | + case DiagID::removed_decl: |
37 | 28 | return "/* Removed Decls */";
|
38 |
| - case LocalDiagID::moved_decl: |
39 |
| - case LocalDiagID::decl_kind_changed: |
| 29 | + case DiagID::moved_decl: |
| 30 | + case DiagID::decl_kind_changed: |
40 | 31 | return "/* Moved Decls */";
|
41 |
| - case LocalDiagID::renamed_decl: |
42 |
| - case LocalDiagID::objc_name_change: |
| 32 | + case DiagID::renamed_decl: |
| 33 | + case DiagID::objc_name_change: |
43 | 34 | return "/* Renamed Decls */";
|
44 |
| - case LocalDiagID::decl_attr_change: |
45 |
| - case LocalDiagID::decl_new_attr: |
46 |
| - case LocalDiagID::func_self_access_change: |
47 |
| - case LocalDiagID::new_decl_without_intro: |
| 35 | + case DiagID::decl_attr_change: |
| 36 | + case DiagID::decl_new_attr: |
| 37 | + case DiagID::func_self_access_change: |
| 38 | + case DiagID::new_decl_without_intro: |
48 | 39 | return "/* Decl Attribute changes */";
|
49 |
| - case LocalDiagID::default_arg_removed: |
50 |
| - case LocalDiagID::decl_type_change: |
51 |
| - case LocalDiagID::func_type_escaping_changed: |
52 |
| - case LocalDiagID::param_ownership_change: |
53 |
| - case LocalDiagID::type_witness_change: |
| 40 | + case DiagID::default_arg_removed: |
| 41 | + case DiagID::decl_type_change: |
| 42 | + case DiagID::func_type_escaping_changed: |
| 43 | + case DiagID::param_ownership_change: |
| 44 | + case DiagID::type_witness_change: |
54 | 45 | return "/* Type Changes */";
|
55 |
| - case LocalDiagID::raw_type_change: |
| 46 | + case DiagID::raw_type_change: |
56 | 47 | return "/* RawRepresentable Changes */";
|
57 |
| - case LocalDiagID::generic_sig_change: |
58 |
| - case LocalDiagID::demangled_name_changed: |
| 48 | + case DiagID::generic_sig_change: |
| 49 | + case DiagID::demangled_name_changed: |
59 | 50 | return "/* Generic Signature Changes */";
|
60 |
| - case LocalDiagID::enum_case_added: |
61 |
| - case LocalDiagID::decl_added: |
62 |
| - case LocalDiagID::decl_reorder: |
63 |
| - case LocalDiagID::var_has_fixed_order_change: |
64 |
| - case LocalDiagID::func_has_fixed_order_change: |
| 51 | + case DiagID::enum_case_added: |
| 52 | + case DiagID::decl_added: |
| 53 | + case DiagID::decl_reorder: |
| 54 | + case DiagID::var_has_fixed_order_change: |
| 55 | + case DiagID::func_has_fixed_order_change: |
65 | 56 | return "/* Fixed-layout Type Changes */";
|
66 |
| - case LocalDiagID::conformance_added: |
67 |
| - case LocalDiagID::conformance_removed: |
68 |
| - case LocalDiagID::optional_req_changed: |
69 |
| - case LocalDiagID::existing_conformance_added: |
| 57 | + case DiagID::conformance_added: |
| 58 | + case DiagID::conformance_removed: |
| 59 | + case DiagID::optional_req_changed: |
| 60 | + case DiagID::existing_conformance_added: |
70 | 61 | return "/* Protocol Conformance Change */";
|
71 |
| - case LocalDiagID::default_associated_type_removed: |
72 |
| - case LocalDiagID::protocol_req_added: |
73 |
| - case LocalDiagID::decl_new_witness_table_entry: |
| 62 | + case DiagID::default_associated_type_removed: |
| 63 | + case DiagID::protocol_req_added: |
| 64 | + case DiagID::decl_new_witness_table_entry: |
74 | 65 | return "/* Protocol Requirement Change */";
|
75 |
| - case LocalDiagID::super_class_removed: |
76 |
| - case LocalDiagID::super_class_changed: |
77 |
| - case LocalDiagID::no_longer_open: |
78 |
| - case LocalDiagID::desig_init_added: |
79 |
| - case LocalDiagID::added_invisible_designated_init: |
80 |
| - case LocalDiagID::not_inheriting_convenience_inits: |
| 66 | + case DiagID::super_class_removed: |
| 67 | + case DiagID::super_class_changed: |
| 68 | + case DiagID::no_longer_open: |
| 69 | + case DiagID::desig_init_added: |
| 70 | + case DiagID::added_invisible_designated_init: |
| 71 | + case DiagID::not_inheriting_convenience_inits: |
81 | 72 | return "/* Class Inheritance Change */";
|
82 | 73 | default:
|
83 | 74 | return "/* Others */";
|
84 | 75 | }
|
85 | 76 | }
|
86 |
| -} |
87 | 77 |
|
88 | 78 | swift::ide::api::
|
89 | 79 | ModuleDifferDiagsConsumer::ModuleDifferDiagsConsumer(bool DiagnoseModuleDiff,
|
90 | 80 | llvm::raw_ostream &OS):
|
91 | 81 | PrintingDiagnosticConsumer(OS), OS(OS),
|
92 | 82 | DiagnoseModuleDiff(DiagnoseModuleDiff) {
|
93 | 83 | #define DIAG(KIND, ID, Group, Options, Text, Signature) \
|
94 |
| - auto ID = getCategoryName(LocalDiagID::ID); \ |
| 84 | + auto ID = getCategoryName(DiagID::ID); \ |
95 | 85 | assert(!ID.empty()); \
|
96 | 86 | AllDiags[ID] = std::set<std::string>();
|
97 | 87 | #include "swift/AST/DiagnosticsModuleDiffer.def"
|
98 | 88 | }
|
99 | 89 |
|
100 | 90 | void swift::ide::api::ModuleDifferDiagsConsumer::handleDiagnostic(
|
101 | 91 | SourceManager &SM, const DiagnosticInfo &Info) {
|
102 |
| - auto Category = getCategoryName((uint32_t)Info.ID); |
| 92 | + auto Category = getCategoryName(Info.ID); |
103 | 93 | if (Category.empty()) {
|
104 | 94 | PrintingDiagnosticConsumer::handleDiagnostic(SM, Info);
|
105 | 95 | return;
|
|
0 commit comments