Index: clang/test/CodeGen/bounds-checking-fam.cpp =================================================================== --- clang/test/CodeGen/bounds-checking-fam.cpp +++ clang/test/CodeGen/bounds-checking-fam.cpp @@ -14,21 +14,43 @@ struct Three { int a[3]; }; +#define FLEXIBLE 1 +struct Macro { + int a[FLEXIBLE]; +}; +struct Base { + int b; +}; +struct NoStandardLayout : Base { + int a[1]; +}; -// CHECK-LABEL: define {{.*}} @test_one( -int test_one(struct One *p, int i) { +// CHECK-LABEL: define {{.*}} @{{.*}}test_one{{.*}}( +int test_one(One *p, int i) { // CHECK-STRICT-0-NOT: @__ubsan return p->a[i] + (p->a)[i]; } -// CHECK-LABEL: define {{.*}} @test_two( -int test_two(struct Two *p, int i) { +// CHECK-LABEL: define {{.*}} @{{.*}}test_two{{.*}}( +int test_two(Two *p, int i) { // CHECK-STRICT-0: call void @__ubsan_handle_out_of_bounds_abort( return p->a[i] + (p->a)[i]; } -// CHECK-LABEL: define {{.*}} @test_three( -int test_three(struct Three *p, int i) { +// CHECK-LABEL: define {{.*}} @{{.*}}test_three{{.*}}( +int test_three(Three *p, int i) { // CHECK-STRICT-0: call void @__ubsan_handle_out_of_bounds_abort( return p->a[i] + (p->a)[i]; } + +// CHECK-LABEL: define {{.*}} @{{.*}}test_macro{{.*}}( +int test_macro(Macro *p, int i) { + // CHECK-STRICT-0-NOT: @__ubsan + return p->a[i] + (p->a)[i]; +} + +// CHECK-LABEL: define {{.*}} @{{.*}}test_nostandardlayout{{.*}}( +int test_nostandardlayout(NoStandardLayout *p, int i) { + // CHECK-STRICT-0-NOT: @__ubsan + return p->a[i] + (p->a)[i]; +}