@@ -46,6 +46,10 @@ template <> struct ScalarEnumerationTraits<LocalDiagID> {
46
46
#define DIAG (KIND, ID, Options, Text, Signature ) \
47
47
io.enumCase (value, #ID, LocalDiagID::ID);
48
48
#include " swift/AST/DiagnosticsAll.def"
49
+ // Ignore diagnostic IDs that are available in the YAML file and not
50
+ // available in the `.def` file.
51
+ if (!io.outputting () && io.matchEnumFallback ())
52
+ value = LocalDiagID::NumDiags;
49
53
}
50
54
};
51
55
@@ -101,12 +105,15 @@ readYAML(llvm::yaml::IO &io, T &Seq, bool, Context &Ctx) {
101
105
DiagnosticNode current;
102
106
yamlize (io, current, true , Ctx);
103
107
io.postflightElement (SaveInfo);
104
- // YAML file isn't guaranteed to have diagnostics in order of their
105
- // declaration in `.def` files, to accommodate that we need to leave
106
- // holes in diagnostic array for diagnostics which haven't yet been
107
- // localized and for the ones that have `DiagnosticNode::id`
108
- // indicates their position.
109
- Seq[static_cast <unsigned >(current.id )] = std::move (current.msg );
108
+
109
+ if (current.id != LocalDiagID::NumDiags) {
110
+ // YAML file isn't guaranteed to have diagnostics in order of their
111
+ // declaration in `.def` files, to accommodate that we need to leave
112
+ // holes in diagnostic array for diagnostics which haven't yet been
113
+ // localized and for the ones that have `DiagnosticNode::id`
114
+ // indicates their position.
115
+ Seq[static_cast <unsigned >(current.id )] = std::move (current.msg );
116
+ }
110
117
}
111
118
}
112
119
io.endSequence ();
0 commit comments