[PATCH] D31097: [clang-tidy] don't warn about implicit widening casts in function calls
Daniel Marjamäki via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 17 13:01:49 PDT 2017
danielmarjamaki created this revision.
Herald added a subscriber: JDevlieghere.
This patch fixes https://bugs.llvm.org/show_bug.cgi?id=32246
To avoid spurious warnings, clang-tidy should not warn about misplaced widening casts for implicit casts in function calls.
Repository:
rL LLVM
https://reviews.llvm.org/D31097
Files:
clang-tidy/misc/MisplacedWideningCastCheck.cpp
test/clang-tidy/misc-misplaced-widening-cast.cpp
Index: test/clang-tidy/misc-misplaced-widening-cast.cpp
===================================================================
--- test/clang-tidy/misc-misplaced-widening-cast.cpp
+++ test/clang-tidy/misc-misplaced-widening-cast.cpp
@@ -45,8 +45,8 @@
}
void call(unsigned int n) {
+ // Don't warn about implicit casts. See https://bugs.llvm.org/show_bug.cgi?id=32246
func(n << 8);
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: either cast from 'unsigned int' to 'long'
func((long)(n << 8));
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: either cast from 'unsigned int' to 'long'
func((long)n << 8);
Index: clang-tidy/misc/MisplacedWideningCastCheck.cpp
===================================================================
--- clang-tidy/misc/MisplacedWideningCastCheck.cpp
+++ clang-tidy/misc/MisplacedWideningCastCheck.cpp
@@ -46,7 +46,7 @@
Finder->addMatcher(varDecl(hasInitializer(Cast)), this);
Finder->addMatcher(returnStmt(hasReturnValue(Cast)), this);
- Finder->addMatcher(callExpr(hasAnyArgument(Cast)), this);
+ Finder->addMatcher(callExpr(hasAnyArgument(ExplicitCast.bind("Cast"))), this);
Finder->addMatcher(binaryOperator(hasOperatorName("="), hasRHS(Cast)), this);
Finder->addMatcher(
binaryOperator(matchers::isComparisonOperator(), hasEitherOperand(Cast)),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31097.92184.patch
Type: text/x-patch
Size: 1307 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170317/fcb150c0/attachment.bin>
More information about the cfe-commits
mailing list