Fix a false positive in misplaced-widening-cast
authorJonas Toth <jonas.toth@gmail.com>
Wed, 5 Dec 2018 08:29:56 +0000 (08:29 +0000)
committerJonas Toth <jonas.toth@gmail.com>
Wed, 5 Dec 2018 08:29:56 +0000 (08:29 +0000)
commitc361e0d62771535284cfb29f4c69be0c76284462
tree7282d563f77933a3141189d862c6c6c85170177d
parent381b4fb0abe02ffa795529b1b88237b79edd5447
Fix a false positive in misplaced-widening-cast

Summary:
bugprone-misplaced-widening-cast check
used to give a false warning to the
following example.

 enum DaysEnum{
    MON = 0,
    TUE = 1
    };

 day = (DaysEnum)(day + 1);
 //warning: either cast from 'int' to 'DaysEnum' is ineffective...

But i think int to enum cast is not widening neither ineffective.

Patch by dkrupp.

Reviewers: JonasToth, alexfh

Reviewed By: alexfh

Subscribers: rnkovacs, Szelethus, gamesh411, cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D55255

llvm-svn: 348341
clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp
clang-tools-extra/test/clang-tidy/bugprone-misplaced-widening-cast-explicit-only.cpp