summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/transpose-memset.c
Commit message (Collapse)AuthorAgeFilesLines
* [Sema] Add some compile time _FORTIFY_SOURCE diagnosticsErik Pilkington2019-03-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | These diagnose overflowing calls to subset of fortifiable functions. Some functions, like sprintf or strcpy aren't supported right not, but we should probably support these in the future. We previously supported this kind of functionality with -Wbuiltin-memcpy-chk-size, but that diagnostic doesn't work with _FORTIFY implementations that use wrapper functions. Also unlike that diagnostic, we emit these warnings regardless of whether _FORTIFY_SOURCE is actually enabled, which is nice for programs that don't enable the runtime checks. Why not just use diagnose_if, like Bionic does? We can get better diagnostics in the compiler (i.e. mention the sizes), and we have the potential to diagnose sprintf and strcpy which is impossible with diagnose_if (at least, in languages that don't support C++14 constexpr). This approach also saves standard libraries from having to add diagnose_if. rdar://48006655 Differential revision: https://reviews.llvm.org/D58797 llvm-svn: 356397
* [Sema] Don't emit -Wmemset-transposed-args for memset(p,0,0)Erik Pilkington2018-07-231-1/+2
| | | | | | Thanks to Arthur O'Dwyer for the suggestion! llvm-svn: 337706
* [Sema] Add a new warning, -Wmemset-transposed-argsErik Pilkington2018-07-191-0/+60
This diagnoses calls to memset that have the second and third arguments transposed, for example: memset(buf, sizeof(buf), 0); This is done by checking if the third argument is a literal 0, or if the second is a sizeof expression (and the third isn't). The first check is also done for calls to bzero. Differential revision: https://reviews.llvm.org/D49112 llvm-svn: 337470
OpenPOWER on IntegriCloud