mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-19 11:35:51 -04:00

Because references must be initialized using some evaluated expression, they must point to something, and a callee can assume the reference parameter is dereferenceable. Taking advantage of a new attribute just added to LLVM, mark them as such. Because dereferenceability in addrspace(0) implies nonnull in the backend, we don't need both attributes. However, we need to know the size of the object to use the dereferenceable attribute, so for incomplete types we still emit only nonnull. llvm-svn: 213386
28 lines
499 B
C++
28 lines
499 B
C++
// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - | \
|
|
// RUN: FileCheck %s
|
|
// RUN: %clang_cc1 -triple i386-apple-darwin -emit-llvm %s -o - | \
|
|
// RUN: FileCheck %s
|
|
|
|
struct A {};
|
|
|
|
struct B
|
|
{
|
|
operator A&();
|
|
};
|
|
|
|
|
|
struct D : public B {
|
|
operator A();
|
|
};
|
|
|
|
extern B f();
|
|
extern D d();
|
|
|
|
int main() {
|
|
const A& rca = f();
|
|
const A& rca2 = d();
|
|
}
|
|
|
|
// CHECK: call dereferenceable({{[0-9]+}}) %struct.A* @_ZN1BcvR1AEv
|
|
// CHECK: call dereferenceable({{[0-9]+}}) %struct.A* @_ZN1BcvR1AEv
|