[PATCH] D129420: [clang-tidy] Initialize boolean variables with 'false' in cppcoreguidelines-init-variables' fix-it
Danny Mösch via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Jul 9 05:50:05 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG33e212954430: [clang-tidy] Initialize boolean variables with `false` in cppcoreguidelines… (authored by SimplyDanny).
Changed prior to commit:
https://reviews.llvm.org/D129420?vs=443429&id=443434#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D129420/new/
https://reviews.llvm.org/D129420
Files:
clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables.cpp
Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables.cpp
+++ 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;
Index: clang-tools-extra/docs/ReleaseNotes.rst
===================================================================
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -247,6 +247,10 @@
<clang-tidy/checks/readability/simplify-boolean-expr>` to simplify expressions
using DeMorgan's Theorem.
+- Made the fix-it of :doc:`cppcoreguidelines-init-variables
+ <clang-tidy/checks/cppcoreguidelines/init-variables>` use ``false`` to initialize
+ boolean variables.
+
Removed checks
^^^^^^^^^^^^^^
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
+++ 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()) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129420.443434.patch
Type: text/x-patch
Size: 1719 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220709/8f396028/attachment.bin>
More information about the cfe-commits
mailing list