Index: clang-tidy/misc/DefinitionsInHeadersCheck.cpp =================================================================== --- clang-tidy/misc/DefinitionsInHeadersCheck.cpp +++ clang-tidy/misc/DefinitionsInHeadersCheck.cpp @@ -139,6 +139,9 @@ // Ignore variable definition within function scope. if (VD->hasLocalStorage() || VD->isStaticLocal()) return; + // Ignore inline variables. + if (VD->isInline()) + return; diag(VD->getLocation(), "variable %0 defined in a header file; " Index: test/clang-tidy/misc-definitions-in-headers-1z.hpp =================================================================== --- /dev/null +++ test/clang-tidy/misc-definitions-in-headers-1z.hpp @@ -0,0 +1,13 @@ +// RUN: %check_clang_tidy %s misc-definitions-in-headers %t -- -- -std=c++1z + +// Inline variables should be ok. +class CE { + constexpr static int i = 5; +}; + +inline int i = 5; + +constexpr int a = 1; + +int b = 1; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: variable 'b' defined in a header file; variable definitions in header files can lead to ODR violations [misc-definitions-in-headers]