xref: /llvm-project/clang/test/CodeGenCXX/dereferenceable.cpp (revision fd739804e0591468762eb87488a497a3f7d4afb0)
1c99fa0b8SRichard Smith // RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-linux-gnu | FileCheck %s
2c99fa0b8SRichard Smith 
3c99fa0b8SRichard Smith struct A { void *p; void *q; void *r; };
4c99fa0b8SRichard Smith 
5c99fa0b8SRichard Smith struct B : A {};
6c99fa0b8SRichard Smith static_assert(sizeof(B) == 24);
7c99fa0b8SRichard Smith 
8*fd739804SFangrui Song // CHECK: define{{.*}} nonnull align 8 dereferenceable(24) {{.*}} @_Z1fR1B({{.*}} nonnull align 8 dereferenceable(24)
f(B & b)9c99fa0b8SRichard Smith B &f(B &b) { return b; }
10c99fa0b8SRichard Smith 
11c99fa0b8SRichard Smith struct C : virtual A {};
12c99fa0b8SRichard Smith static_assert(sizeof(C) == 32);
13c99fa0b8SRichard Smith 
14*fd739804SFangrui Song // CHECK: define{{.*}} nonnull align 8 dereferenceable(8) {{.*}} @_Z1fR1C({{.*}} nonnull align 8 dereferenceable(8)
f(C & c)15c99fa0b8SRichard Smith C &f(C &c) { return c; }
16