diff --git a/clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp b/clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp --- a/clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp @@ -149,6 +149,9 @@ // Ignore inline variables. if (VD->isInline()) return; + // Ignore partial specializations. + if (isa(VD)) + return; diag(VD->getLocation(), "variable %0 defined in a header file; " diff --git a/clang-tools-extra/test/clang-tidy/checkers/misc-definitions-in-headers.hpp b/clang-tools-extra/test/clang-tidy/checkers/misc-definitions-in-headers.hpp --- a/clang-tools-extra/test/clang-tidy/checkers/misc-definitions-in-headers.hpp +++ b/clang-tools-extra/test/clang-tidy/checkers/misc-definitions-in-headers.hpp @@ -193,6 +193,16 @@ // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: full function template specialization 'f12' defined in a header file; // CHECK-FIXES: inline const int f12() { return 0; } +template +constexpr bool f13 = false; + +template +constexpr bool f13 = true; // OK: template partial specialization + +template <> +constexpr bool f13 = false; +// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: variable 'f13' defined in a header file; + int main() {} // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'main' defined in a header file; // CHECK-FIXES: {{^}}int main() {