brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · 53e324c Raw
53 lines · cpp
1// RUN: %clang_cc1 -x c++ -triple x86_64-apple-darwin10 -emit-llvm -o - %s -fsanitize=nullability-arg | FileCheck %s -check-prefixes=ITANIUM,ALL2// RUN: %clang_cc1 -x c++ -triple x86_64-pc-windows-msvc -emit-llvm -o - %s -fsanitize=nullability-arg | FileCheck %s -check-prefixes=MSVC,ALL3 4namespace method_ptr {5 6struct S0 {7  void foo1();8};9 10void foo1(void (S0::*_Nonnull f)());11 12// ITANIUM-LABEL: @_ZN10method_ptr5test1Ev(){{.*}} {13// ITANIUM: [[CMP:%.*]] = icmp ne i64 ptrtoint (ptr @_ZN10method_ptr2S04foo1Ev to i64), 014// ITANIUM: br i1 [[CMP]], label %[[CONT:.*]], label %[[FAIL:[^,]*]]15// ITANIUM-EMPTY:16// ITANIUM-NEXT: [[FAIL]]:17// ITANIUM-NEXT:   call void @__ubsan_handle_nullability_arg18 19// MSVC-LABEL: @"?test1@method_ptr@@YAXXZ"(){{.*}} {20// MSVC: br i1 true, label %[[CONT:.*]], label %[[FAIL:[^,]*]]21// MSVC-EMPTY:22// MSVC-NEXT: [[FAIL]]:23// MSVC-NEXT:   call void @__ubsan_handle_nullability_arg24void test1() {25  foo1(&S0::foo1);26}27 28} // namespace method_ptr29 30namespace data_ptr {31 32struct S0 {33  int field1;34};35 36using member_ptr = int S0::*;37 38void foo1(member_ptr _Nonnull);39 40// ITANIUM-LABEL: @_ZN8data_ptr5test1ENS_2S0E(41// MSVC-LABEL: @"?test1@data_ptr@@YAXUS0@1@@Z"(42// ALL: [[DATA_PTR_CHECK:%.*]] = icmp ne {{.*}}, -1, !nosanitize43// ALL-NEXT: br i1 [[DATA_PTR_CHECK]], label %[[CONT:.*]], label %[[FAIL:[^,]+]]44// ALL-EMPTY:45// ALL-NEXT: [[FAIL]]:46// ALL-NEXT:   call void @__ubsan_handle_nullability_arg47void test1(S0 s) {48  int S0::*member = &S0::field1;49  foo1(member);50}51 52} // namespace data_ptr53