diff options
author | Duncan Sands <baldrick@free.fr> | 2012-09-26 07:45:36 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2012-09-26 07:45:36 +0000 |
commit | c7c42f71aad7d33892de73d6d6397e38814b0e97 (patch) | |
tree | 92e9bca7e906b0676ac4962fdd2e3d23929d9d53 /test/Other | |
parent | 02f790e53445b1ded08da61ae659496241afd1aa (diff) | |
download | llvm-c7c42f71aad7d33892de73d6d6397e38814b0e97.tar.gz |
Teach the 'lint' sanity checking pass to detect simple buffer overflows.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164671 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Other')
-rw-r--r-- | test/Other/lint.ll | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/Other/lint.ll b/test/Other/lint.ll index f6787e973ed7..d3ab98872d71 100644 --- a/test/Other/lint.ll +++ b/test/Other/lint.ll @@ -79,6 +79,18 @@ define i32 @foo() noreturn { ; CHECK: Write to read-only memory call void @llvm.memcpy.p0i8.p0i8.i64(i8* bitcast (i32* @CG to i8*), i8* bitcast (i32* @CG to i8*), i64 1, i32 1, i1 0) +; CHECK: Undefined behavior: Buffer overflow + %wider = bitcast i8* %buf to i16* + store i16 0, i16* %wider +; CHECK: Undefined behavior: Buffer overflow + %inner = getelementptr {i8, i8}* %buf2, i32 0, i32 1 + %wider2 = bitcast i8* %inner to i16* + store i16 0, i16* %wider2 +; CHECK: Undefined behavior: Buffer overflow + %before = getelementptr i8* %buf, i32 -1 + %wider3 = bitcast i8* %before to i16* + store i16 0, i16* %wider3 + br label %next next: |