[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGen / delete-null-pointer-checks.c
blob78bfeb495b3cdf09862c2c798a7d9b247aa85179
1 // RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-linux-gnu -O2 -o - %s | FileCheck -check-prefix=NULL-POINTER-INVALID %s
2 // RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-linux-gnu -O2 -o - %s -fno-delete-null-pointer-checks | FileCheck -check-prefix=NULL-POINTER-VALID %s
4 // Test that clang does not remove the null pointer check with
5 // -fno-delete-null-pointer-checks.
6 int null_check(int *P) {
7 // NULL-POINTER-VALID: %[[TOBOOL:.*]] = icmp eq ptr %P, null
8 // NULL-POINTER-INVALID-NOT: icmp eq
9 // NULL-POINTER-VALID: %[[SEL:.*]] = select i1 %[[TOBOOL:.*]], ptr null, ptr
10 // NULL-POINTER-INVALID-NOT: select i1
11 // NULL-POINTER-VALID: load i32, ptr %[[SEL:.*]]
12 int *Q = P;
13 if (P) {
14 Q = P + 2;
16 return *Q;
19 // NULL-POINTER-INVALID-NOT: attributes #0 = {{.*}} null_pointer_is_valid
20 // NULL-POINTER-VALID: attributes #0 = {{.*}} null_pointer_is_valid