summaryrefslogtreecommitdiff
path: root/test/Analysis/null-deref-ps-region.c
diff options
context:
space:
mode:
authorErik Pilkington <erik.pilkington@gmail.com>2019-03-18 19:23:45 +0000
committerErik Pilkington <erik.pilkington@gmail.com>2019-03-18 19:23:45 +0000
commit25d062ee4f1b683ccfeefb177d289eac901851cc (patch)
treec615a23ae85936a1088992c6024f524b8e270665 /test/Analysis/null-deref-ps-region.c
parent2bc6178db36348e53054ce2f5b7816da1bae580e (diff)
downloadclang-25d062ee4f1b683ccfeefb177d289eac901851cc.tar.gz
[Sema] Add some compile time _FORTIFY_SOURCE diagnostics
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356397 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/null-deref-ps-region.c')
-rw-r--r--test/Analysis/null-deref-ps-region.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/test/Analysis/null-deref-ps-region.c b/test/Analysis/null-deref-ps-region.c
index f5e6956ff7..2bc338cd3f 100644
--- a/test/Analysis/null-deref-ps-region.c
+++ b/test/Analysis/null-deref-ps-region.c
@@ -51,7 +51,7 @@ void testHeapSymbol() {
void testStackArrayOutOfBound() {
char buf[1];
- memset(buf, 0, 1024); // expected-warning {{Memory set function accesses out-of-bound array element}}
+ memset(buf, 0, 1024); // expected-warning {{Memory set function accesses out-of-bound array element}} expected-warning {{'memset' will always overflow; destination buffer has size 1, but size argument is 1024}}
}
void testHeapSymbolOutOfBound() {