summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Marjamaki <daniel.marjamaki@evidente.se>2016-02-12 09:38:38 +0000
committerDaniel Marjamaki <daniel.marjamaki@evidente.se>2016-02-12 09:38:38 +0000
commit1fba76a3b936d288980020af62021ee4b3651781 (patch)
tree3d428de4f174459115efc106be7f10c2a8c096ab
parent057df3d423729606aa5ffc3c6c830ed940716eae (diff)
downloadbcm5719-llvm-1fba76a3b936d288980020af62021ee4b3651781.tar.gz
bcm5719-llvm-1fba76a3b936d288980020af62021ee4b3651781.zip
[clang-tidy] Fix failure in 'misc-misplaced-widening-cast' test.
I added portability warnings when int results are casted to long. I forgot to handle uint, ulong and ulonglong. Tested on x86 and powerpc targets, hope it works now on all buildbots. llvm-svn: 260667
-rw-r--r--clang-tools-extra/clang-tidy/misc/MisplacedWideningCastCheck.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/clang-tools-extra/clang-tidy/misc/MisplacedWideningCastCheck.cpp b/clang-tools-extra/clang-tidy/misc/MisplacedWideningCastCheck.cpp
index 0006131f20f..a1666c5686f 100644
--- a/clang-tools-extra/clang-tidy/misc/MisplacedWideningCastCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/MisplacedWideningCastCheck.cpp
@@ -96,14 +96,19 @@ void MisplacedWideningCastCheck::check(const MatchFinder::MatchResult &Result) {
// If CalcType and CastType have same size then there is no real danger, but
// there can be a portability problem.
if (Context.getIntWidth(CastType) == Context.getIntWidth(CalcType)) {
- if (CalcType->isSpecificBuiltinType(BuiltinType::Int)) {
+ if (CalcType->isSpecificBuiltinType(BuiltinType::Int) ||
+ CalcType->isSpecificBuiltinType(BuiltinType::UInt)) {
// There should be a warning when casting from int to long or long long.
if (!CastType->isSpecificBuiltinType(BuiltinType::Long) &&
- !CastType->isSpecificBuiltinType(BuiltinType::LongLong))
+ !CastType->isSpecificBuiltinType(BuiltinType::ULong) &&
+ !CastType->isSpecificBuiltinType(BuiltinType::LongLong) &&
+ !CastType->isSpecificBuiltinType(BuiltinType::ULongLong))
return;
- } else if (CalcType->isSpecificBuiltinType(BuiltinType::Long)) {
+ } else if (CalcType->isSpecificBuiltinType(BuiltinType::Long) ||
+ CalcType->isSpecificBuiltinType(BuiltinType::ULong)) {
// There should be a warning when casting from long to long long.
- if (!CastType->isSpecificBuiltinType(BuiltinType::LongLong))
+ if (!CastType->isSpecificBuiltinType(BuiltinType::LongLong) &&
+ !CastType->isSpecificBuiltinType(BuiltinType::ULongLong))
return;
} else {
return;
OpenPOWER on IntegriCloud