[clang-tools-extra] [clang-tidy]suggest use `std::span` as replacement of c array in C++20 for modernize-avoid-c-arrays (PR #108555)

Carlos Galvez via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 16 13:14:29 PDT 2024


================
@@ -10,29 +10,32 @@ modernize-avoid-c-arrays
 Finds C-style array types and recommend to use ``std::array<>`` /
 ``std::vector<>``. All types of C arrays are diagnosed.
 
+For parameters of incomplete C-style array type, it would be better to
+use ``std::span`` / ``gsl::span`` as replacement.
+
 However, fix-it are potentially dangerous in header files and are therefore not
 emitted right now.
 
 .. code:: c++
 
-  int a[] = {1, 2}; // warning: do not declare C-style arrays, use std::array<> instead
+  int a[] = {1, 2}; // warning: do not declare C-style arrays, use 'std::array<>' instead
----------------
carlosgalvezp wrote:

Nit: is adding the single quotes needed for this patch? It introduces quite some review noise. It'd be preferable to apply this as a separate (NFC?) patch.

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


More information about the cfe-commits mailing list