[PATCH] D59859: [clang-tidy] FIXIT for implicit bool conversion now obeys upper case suffixes if enforced.

Patrick Nappa via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 26 18:33:30 PDT 2019


pnappa created this revision.
pnappa added a reviewer: lebedev.ri.
pnappa added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, jdoerfert, xazax.hun.
Herald added a project: clang.

Fix for https://bugs.llvm.org/show_bug.cgi?id=41199#c1

Previously, if a user implicitly cast to a bool (say, in a conditional statement), the fix would be to add an explicit comparison. So, for a floating point implicit case to bool, from `if (f)`, the synthesised code would be `if (f != 0.0f)`.

Even if the flag "readability-uppercase-literal-suffix" was enabled, the synthesised suffix would be lowercase. This commit changes that, such that if that flag is enabled when "readability-implicit-bool-conversion" is enabled, the synthesised suffix is uppercase.

A non-covered case is when "modernize-use-default-member-init" is enabled, lower-case suffixes may still be synthesised (I think, based off the code). Any RFC whether this should be made a different issue or whether or not this behaviour should be added in?

Intended as my first commit to the llvm-project.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D59859

Files:
  clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
  clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.h
  clang-tools-extra/test/clang-tidy/readability-implicit-bool-conversion.cpp
  clang-tools-extra/test/clang-tidy/readability-uppercase-literal-suffix-implicit-bool-conversion.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59859.192396.patch
Type: text/x-patch
Size: 11941 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190327/88a6257a/attachment-0001.bin>


More information about the cfe-commits mailing list