[PATCH] D54943: [clang-tidy] implement const-transformation for cppcoreguidelines-const-correctness

Florin Iucha via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 3 18:58:48 PST 2020


0x8000-0000 added a comment.

In D54943#1803448 <https://reviews.llvm.org/D54943#1803448>, @JonasToth wrote:

> In D54943#1800182 <https://reviews.llvm.org/D54943#1800182>, @0x8000-0000 wrote:
>
> > F11163406: 0001-Add-extra-tests.patch <https://reviews.llvm.org/F11163406> shows a couple of false positives.
>
>
> I added your tests, but some did not show false positives anymore. I think i will remove some, that i find redundant.
>  But could you please recheck with the current version first, if this is actually correct and the original false positives are gone?


I can confirm that the false positives in the real code have been cleaned up. Thank you!

However I would be loath to discard tests - unless we can prove they are truly redundant.

Also, here is a new test for you - it trips now on "unsigned someValue = 0;" line:

  struct IntWrapper {
     unsigned low;
     unsigned high;
  
     IntWrapper& operator=(unsigned value) {
        low = value & 0xffff;
        high = (value >> 16) & 0xffff;
     }
  
     template<typename Istream>
     friend Istream& operator>>(Istream& is, IntWrapper& rhs) {
        unsigned someValue = 0;
        if (is >> someValue) {
           rhs = someValue;
        }
        return is;
     }
  };
  
  
  unsigned TestHiddenFriend(IntMaker& im) {
     IntWrapper iw;
  
     im >> iw;
  
     return iw.low;
  }


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54943/new/

https://reviews.llvm.org/D54943





More information about the cfe-commits mailing list