From c7c42f71aad7d33892de73d6d6397e38814b0e97 Mon Sep 17 00:00:00 2001 From: Duncan Sands Date: Wed, 26 Sep 2012 07:45:36 +0000 Subject: 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 --- test/Other/lint.ll | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/Other') diff --git a/test/Other/lint.ll b/test/Other/lint.ll index f6787e973e..d3ab98872d 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: -- cgit v1.2.3