[clang] [Clang][Diagnostics] Update select uses in DiagnosticXKinds.td to use enum_select (PR #130868)

via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 13 06:04:47 PDT 2025


================
@@ -131,17 +131,21 @@ def note_constexpr_past_end : Note<
   "dereferenced pointer past the end of %select{|subobject of }0"
   "%select{temporary|%2}1 is not a constant expression">;
 def note_constexpr_past_end_subobject : Note<
-  "cannot %select{access base class of|access derived class of|access field of|"
-  "access array element of|ERROR|"
-  "access real component of|access imaginary component of}0 "
-  "pointer past the end of object">;
+  "cannot %enum_select<AccessType>{"
+    "%BaseClassAccess{access base class of}|%DerivedClassAccess{access derived class of}|"
+    "%FieldAccess{access field of}|%ArrayElementAccess{access array element of}|"
+    "%ErrorAccess{ERROR}|"
+    "%RealComponentAccess{access real component of}|%ImaginaryComponentAccess{access imaginary component of}"
+  "}0 pointer past the end of object">;
 def note_non_null_attribute_failed : Note<
   "null passed to a callee that requires a non-null argument">;
 def note_constexpr_null_subobject : Note<
-  "cannot %select{access base class of|access derived class of|access field of|"
-  "access array element of|perform pointer arithmetic on|"
-  "access real component of|"
-  "access imaginary component of}0 null pointer">;
+  "cannot %enum_select<NullSubobjectAccess>{"
----------------
Sirraide wrote:

> additionally

Or actually, maybe *instead* rather than *additionally*? I.e. don’t allow `%enum_select<T>{...}` for the same `T` multiple times, but instead only allow referencing an existing `enum_select` by writing e.g. just `%enum_select<T>0` rather than `%enum_select<T>{...}0`. That would also save us from having to check whether two definitions of an `enum_select` are actually the same.

https://github.com/llvm/llvm-project/pull/130868


More information about the cfe-commits mailing list