CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
76 lines
2.0 KiB
ReStructuredText
76 lines
2.0 KiB
ReStructuredText
.. title:: clang-tidy - modernize-avoid-c-arrays
|
|
|
|
modernize-avoid-c-arrays
|
|
========================
|
|
|
|
`cppcoreguidelines-avoid-c-arrays` redirects here as an alias for this check.
|
|
|
|
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 b[1]; // warning: do not declare C-style arrays, use 'std::array' instead
|
|
|
|
void foo() {
|
|
int c[b[0]]; // warning: do not declare C VLA arrays, use 'std::vector' instead
|
|
}
|
|
|
|
template <typename T, int Size>
|
|
class array {
|
|
T d[Size]; // warning: do not declare C-style arrays, use 'std::array' instead
|
|
|
|
int e[1]; // warning: do not declare C-style arrays, use 'std::array' instead
|
|
};
|
|
|
|
array<int[4], 2> d; // warning: do not declare C-style arrays, use 'std::array' instead
|
|
|
|
using k = int[4]; // warning: do not declare C-style arrays, use 'std::array' instead
|
|
|
|
|
|
However, the ``extern "C"`` code is ignored, since it is common to share
|
|
such headers between C code, and C++ code.
|
|
|
|
.. code:: c++
|
|
|
|
// Some header
|
|
extern "C" {
|
|
|
|
int f[] = {1, 2}; // not diagnosed
|
|
|
|
int j[1]; // not diagnosed
|
|
|
|
inline void bar() {
|
|
{
|
|
int j[j[0]]; // not diagnosed
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
Similarly, the ``main()`` function is ignored. Its second and third parameters
|
|
can be either ``char* argv[]`` or ``char** argv``, but cannot be
|
|
``std::array<>``.
|
|
|
|
Options
|
|
-------
|
|
|
|
.. option:: AllowStringArrays
|
|
|
|
When set to `true` (default is `false`), variables of character array type
|
|
with deduced length, initialized directly from string literals, will be ignored.
|
|
This option doesn't affect cases where length can't be deduced, resembling
|
|
pointers, as seen in class members and parameters. Example:
|
|
|
|
.. code:: c++
|
|
|
|
const char name[] = "Some name";
|