diff --git a/infer/src/llvm/examples/null_deref.c b/infer/src/llvm/examples/null_deref.c new file mode 100644 index 000000000..01201b7b1 --- /dev/null +++ b/infer/src/llvm/examples/null_deref.c @@ -0,0 +1,4 @@ +void foo(void) { + int *p = 0; + *p = 42; +} diff --git a/infer/src/llvm/examples/null_deref.ll b/infer/src/llvm/examples/null_deref.ll new file mode 100644 index 000000000..52d06ee34 --- /dev/null +++ b/infer/src/llvm/examples/null_deref.ll @@ -0,0 +1,18 @@ +; ModuleID = 'null_deref.c' +target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-apple-macosx10.10.0" + +; Function Attrs: nounwind ssp uwtable +define void @foo() #0 { + %p = alloca i32*, align 8 + store i32* null, i32** %p, align 8 + %1 = load i32** %p, align 8 + store i32 42, i32* %1, align 4 + ret void +} + +attributes #0 = { nounwind ssp uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!llvm.ident = !{!0} + +!0 = metadata !{metadata !"Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)"}