[PATCH] D59802: [clang-tidy] Add new checker: llvm-avoid-cast-in-conditional
Don Hinton via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 25 15:21:00 PDT 2019
hintonda created this revision.
hintonda added reviewers: alexfh, rjmccall.
Herald added subscribers: xazax.hun, mgorny.
Herald added a project: clang.
Finds cases of cast<> used as the condition of a conditional
statements which will assert on failure in Debug builds. The use of
cast<> implies that the operation cannot fail, and should not be used
as the condition of a conditional statement..
.. code-block:: c++
// Finds cases like these:
if (auto x = cast<X>(y)) <...>
if (cast<X>(y)) <...>
// But not cases like these:
if (auto f = cast<Z>(y)->foo()) <...>
if (cast<Z>(y)->foo()) <...>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D59802
Files:
clang-tools-extra/clang-tidy/llvm/AvoidCastInConditionalCheck.cpp
clang-tools-extra/clang-tidy/llvm/AvoidCastInConditionalCheck.h
clang-tools-extra/clang-tidy/llvm/CMakeLists.txt
clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst
clang-tools-extra/docs/clang-tidy/checks/llvm-avoid-cast-in-conditional.rst
clang-tools-extra/test/clang-tidy/llvm-avoid-cast-in-conditional.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59802.192214.patch
Type: text/x-patch
Size: 8672 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190325/949b8d79/attachment.bin>
More information about the cfe-commits
mailing list