Skip to content

Commit c642816

Browse files
authored
[NFC] Deduplicate clang::AccessKinds to diagnostic strings (llvm#102030)
1 parent dc21cb5 commit c642816

File tree

1 file changed

+24
-40
lines changed

1 file changed

+24
-40
lines changed

clang/include/clang/Basic/DiagnosticASTKinds.td

Lines changed: 24 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,22 @@ def note_constexpr_heap_alloc_limit_exceeded : Note<
166166
def note_constexpr_this : Note<
167167
"%select{|implicit }0use of 'this' pointer is only allowed within the "
168168
"evaluation of a call to a 'constexpr' member function">;
169-
def note_constexpr_lifetime_ended : Note<
169+
def access_kind : TextSubstitution<
170170
"%select{read of|read of|assignment to|increment of|decrement of|"
171171
"member call on|dynamic_cast of|typeid applied to|construction of|"
172-
"destruction of}0 %select{temporary|variable}1 whose "
173-
"%plural{8:storage duration|:lifetime}0 has ended">;
174-
def note_constexpr_access_uninit : Note<
172+
"destruction of}0">;
173+
def access_kind_subobject : TextSubstitution<
175174
"%select{read of|read of|assignment to|increment of|decrement of|"
176175
"member call on|dynamic_cast of|typeid applied to|"
177-
"construction of subobject of|destruction of}0 "
176+
"construction of subobject of|destruction of}0">;
177+
def access_kind_volatile : TextSubstitution<
178+
"%select{read of|read of|assignment to|increment of|decrement of|"
179+
"<ERROR>|<ERROR>|<ERROR>|<ERROR>|<ERROR>}0">;
180+
def note_constexpr_lifetime_ended : Note<
181+
"%sub{access_kind}0 %select{temporary|variable}1 whose "
182+
"%plural{8:storage duration|:lifetime}0 has ended">;
183+
def note_constexpr_access_uninit : Note<
184+
"%sub{access_kind_subobject}0 "
178185
"%select{object outside its lifetime|uninitialized object}1 "
179186
"is not allowed in a constant expression">;
180187
def note_constexpr_use_uninit_reference : Note<
@@ -184,20 +191,16 @@ def note_constexpr_modify_const_type : Note<
184191
"modification of object of const-qualified type %0 is not allowed "
185192
"in a constant expression">;
186193
def note_constexpr_access_volatile_type : Note<
187-
"%select{read of|read of|assignment to|increment of|decrement of|"
188-
"<ERROR>|<ERROR>|<ERROR>|<ERROR>}0 "
194+
"%sub{access_kind_volatile}0 "
189195
"volatile-qualified type %1 is not allowed in a constant expression">;
190196
def note_constexpr_access_volatile_obj : Note<
191-
"%select{read of|read of|assignment to|increment of|decrement of|"
192-
"<ERROR>|<ERROR>|<ERROR>|<ERROR>}0 "
197+
"%sub{access_kind_volatile}0 "
193198
"volatile %select{temporary|object %2|member %2}1 is not allowed in "
194199
"a constant expression">;
195200
def note_constexpr_volatile_here : Note<
196201
"volatile %select{temporary created|object declared|member declared}0 here">;
197202
def note_constexpr_access_mutable : Note<
198-
"%select{read of|read of|assignment to|increment of|decrement of|"
199-
"member call on|dynamic_cast of|typeid applied to|construction of|"
200-
"destruction of}0 "
203+
"%sub{access_kind}0 "
201204
"mutable member %1 is not allowed in a constant expression">;
202205
def note_constexpr_ltor_non_const_int : Note<
203206
"read of non-const variable %0 is not allowed in a constant expression">;
@@ -209,47 +212,28 @@ def note_constexpr_ltor_non_constexpr : Note<
209212
def note_constexpr_ltor_incomplete_type : Note<
210213
"read of incomplete type %0 is not allowed in a constant expression">;
211214
def note_constexpr_access_null : Note<
212-
"%select{read of|read of|assignment to|increment of|decrement of|"
213-
"member call on|dynamic_cast of|typeid applied to|construction of|"
214-
"destruction of}0 "
215+
"%sub{access_kind}0 "
215216
"dereferenced null pointer is not allowed in a constant expression">;
216217
def note_constexpr_access_past_end : Note<
217-
"%select{read of|read of|assignment to|increment of|decrement of|"
218-
"member call on|dynamic_cast of|typeid applied to|construction of|"
219-
"destruction of}0 "
220-
"dereferenced one-past-the-end pointer is not allowed "
221-
"in a constant expression">;
218+
"%sub{access_kind}0 dereferenced one-past-the-end pointer "
219+
"is not allowed in a constant expression">;
222220
def note_constexpr_access_unsized_array : Note<
223-
"%select{read of|read of|assignment to|increment of|decrement of|"
224-
"member call on|dynamic_cast of|typeid applied to|construction of|"
225-
"destruction of}0 "
226-
"element of array without known bound "
221+
"%sub{access_kind}0 element of array without known bound "
227222
"is not allowed in a constant expression">;
228223
def note_constexpr_access_inactive_union_member : Note<
229-
"%select{read of|read of|assignment to|increment of|decrement of|"
230-
"member call on|dynamic_cast of|typeid applied to|"
231-
"construction of subobject of|destruction of}0 "
224+
"%sub{access_kind_subobject}0 "
232225
"member %1 of union with %select{active member %3|no active member}2 "
233226
"is not allowed in a constant expression">;
234227
def note_constexpr_union_member_change_during_init : Note<
235228
"assignment would change active union member during the initialization of "
236229
"a different member of the same union">;
237230
def note_constexpr_access_static_temporary : Note<
238-
"%select{read of|read of|assignment to|increment of|decrement of|"
239-
"member call on|dynamic_cast of|typeid applied to|reconstruction of|"
240-
"destruction of}0 temporary "
241-
"is not allowed in a constant expression outside the expression that "
242-
"created the temporary">;
231+
"%sub{access_kind}0 temporary is not allowed in a constant expression "
232+
"outside the expression that created the temporary">;
243233
def note_constexpr_access_unreadable_object : Note<
244-
"%select{read of|read of|assignment to|increment of|decrement of|"
245-
"member call on|dynamic_cast of|typeid applied to|construction of|"
246-
"destruction of}0 "
247-
"object '%1' whose value is not known">;
234+
"%sub{access_kind}0 object '%1' whose value is not known">;
248235
def note_constexpr_access_deleted_object : Note<
249-
"%select{read of|read of|assignment to|increment of|decrement of|"
250-
"member call on|dynamic_cast of|typeid applied to|construction of|"
251-
"destruction of}0 "
252-
"heap allocated object that has been deleted">;
236+
"%sub{access_kind}0 heap allocated object that has been deleted">;
253237
def note_constexpr_modify_global : Note<
254238
"a constant expression cannot modify an object that is visible outside "
255239
"that expression">;

0 commit comments

Comments
 (0)