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
95 lines
2.4 KiB
ReStructuredText
95 lines
2.4 KiB
ReStructuredText
.. title:: clang-tidy - misc-definitions-in-headers
|
|
|
|
misc-definitions-in-headers
|
|
===========================
|
|
|
|
Finds non-extern non-inline function and variable definitions in header files,
|
|
which can lead to potential ODR violations in case these headers are included
|
|
from multiple translation units.
|
|
|
|
.. code-block:: c++
|
|
|
|
// Foo.h
|
|
int a = 1; // Warning: variable definition.
|
|
extern int d; // OK: extern variable.
|
|
|
|
namespace N {
|
|
int e = 2; // Warning: variable definition.
|
|
}
|
|
|
|
// Warning: variable definition.
|
|
const char* str = "foo";
|
|
|
|
// OK: internal linkage variable definitions are ignored for now.
|
|
// Although these might also cause ODR violations, we can be less certain and
|
|
// should try to keep the false-positive rate down.
|
|
static int b = 1;
|
|
const int c = 1;
|
|
const char* const str2 = "foo";
|
|
constexpr int k = 1;
|
|
namespace { int x = 1; }
|
|
|
|
// Warning: function definition.
|
|
int g() {
|
|
return 1;
|
|
}
|
|
|
|
// OK: inline function definition is allowed to be defined multiple times.
|
|
inline int e() {
|
|
return 1;
|
|
}
|
|
|
|
class A {
|
|
public:
|
|
int f1() { return 1; } // OK: implicitly inline member function definition is allowed.
|
|
int f2();
|
|
|
|
static int d;
|
|
};
|
|
|
|
// Warning: not an inline member function definition.
|
|
int A::f2() { return 1; }
|
|
|
|
// OK: class static data member declaration is allowed.
|
|
int A::d = 1;
|
|
|
|
// OK: function template is allowed.
|
|
template<typename T>
|
|
T f3() {
|
|
T a = 1;
|
|
return a;
|
|
}
|
|
|
|
// Warning: full specialization of a function template is not allowed.
|
|
template <>
|
|
int f3() {
|
|
int a = 1;
|
|
return a;
|
|
}
|
|
|
|
template <typename T>
|
|
struct B {
|
|
void f1();
|
|
};
|
|
|
|
// OK: member function definition of a class template is allowed.
|
|
template <typename T>
|
|
void B<T>::f1() {}
|
|
|
|
class CE {
|
|
constexpr static int i = 5; // OK: inline variable definition.
|
|
};
|
|
|
|
inline int i = 5; // OK: inline variable definition.
|
|
|
|
constexpr int f10() { return 0; } // OK: constexpr function implies inline.
|
|
|
|
// OK: C++14 variable templates are inline.
|
|
template <class T>
|
|
constexpr T pi = T(3.1415926L);
|
|
|
|
When :program:`clang-tidy` is invoked with the `--fix-notes` option, this check
|
|
provides fixes that automatically add the ``inline`` keyword to discovered
|
|
functions. Please note that the addition of the ``inline`` keyword to variables
|
|
is not currently supported by this check.
|