diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp @@ -84,6 +84,8 @@ if (TypePtr->isEnumeralType()) InitializationString = nullptr; + else if (TypePtr->isBooleanType()) + InitializationString = " = false"; else if (TypePtr->isIntegerType()) InitializationString = " = 0"; else if (TypePtr->isFloatingType()) { diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -247,6 +247,10 @@ ` to simplify expressions using DeMorgan's Theorem. +- Made the fix-it of :doc:`cppcoreguidelines-init-variables + ` use ``false`` to initialize + boolean variables. + Removed checks ^^^^^^^^^^^^^^ diff --git a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables.cpp b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables.cpp --- a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables.cpp @@ -64,7 +64,7 @@ bool b; // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: variable 'b' is not initialized [cppcoreguidelines-init-variables] - // CHECK-FIXES: {{^}} bool b = 0;{{$}} + // CHECK-FIXES: {{^}} bool b = false;{{$}} bool bval = true; const char *ptr;