summaryrefslogtreecommitdiffstats
path: root/llvm/test/Other
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-04-08 18:47:09 +0000
committerDan Gohman <gohman@apple.com>2010-04-08 18:47:09 +0000
commit98bc4371c72a52defde84b9993a60e88e21ed968 (patch)
treee1348c07aed9cf309c9041a9113de9ddb6449e08 /llvm/test/Other
parent359b013129d3e7ae802a46552f0069f16d8b93a8 (diff)
downloadbcm5719-llvm-98bc4371c72a52defde84b9993a60e88e21ed968.tar.gz
bcm5719-llvm-98bc4371c72a52defde84b9993a60e88e21ed968.zip
Add a -lint pass which checks for common sources of undefined or likely
unintended behavior. llvm-svn: 100798
Diffstat (limited to 'llvm/test/Other')
-rw-r--r--llvm/test/Other/lint.ll31
1 files changed, 31 insertions, 0 deletions
diff --git a/llvm/test/Other/lint.ll b/llvm/test/Other/lint.ll
new file mode 100644
index 00000000000..6ccaa6fd4c4
--- /dev/null
+++ b/llvm/test/Other/lint.ll
@@ -0,0 +1,31 @@
+; RUN: opt -lint -disable-output < %s |& FileCheck %s
+target datalayout = "e-p:64:64:64"
+
+declare fastcc void @bar()
+
+define i32 @foo() noreturn {
+; CHECK: Caller and callee calling convention differ
+ call void @bar()
+; CHECK: Null pointer dereference
+ store i32 0, i32* null
+; CHECK: Null pointer dereference
+ %t = load i32* null
+; CHECK: Memory reference address is misaligned
+ %x = inttoptr i32 1 to i32*
+ load i32* %x, align 4
+; CHECK: Division by zero
+ %sd = sdiv i32 2, 0
+; CHECK: Division by zero
+ %ud = udiv i32 2, 0
+; CHECK: Division by zero
+ %sr = srem i32 2, 0
+; CHECK: Division by zero
+ %ur = urem i32 2, 0
+ br label %next
+
+next:
+; CHECK: Static alloca outside of entry block
+ %a = alloca i32
+; CHECK: Return statement in function with noreturn attribute
+ ret i32 0
+}
OpenPOWER on IntegriCloud