diff options
author | Hal Finkel <hfinkel@anl.gov> | 2014-07-18 15:52:10 +0000 |
---|---|---|
committer | Hal Finkel <hfinkel@anl.gov> | 2014-07-18 15:52:10 +0000 |
commit | a2347baaec37ba81d64f9b455af3084cf183f127 (patch) | |
tree | 38de0cdf097468df1afb29d2abb642bf7bdab1f1 /clang/test/CodeGenCXX/reference-cast.cpp | |
parent | b0407ba0716d940d035f5da73f6d3bfbaffecb44 (diff) | |
download | bcm5719-llvm-a2347baaec37ba81d64f9b455af3084cf183f127.tar.gz bcm5719-llvm-a2347baaec37ba81d64f9b455af3084cf183f127.zip |
Mark C++ reference parameters as dereferenceable
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
Diffstat (limited to 'clang/test/CodeGenCXX/reference-cast.cpp')
-rw-r--r-- | clang/test/CodeGenCXX/reference-cast.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/clang/test/CodeGenCXX/reference-cast.cpp b/clang/test/CodeGenCXX/reference-cast.cpp index 0596ceb3b42..c4be5b78c2e 100644 --- a/clang/test/CodeGenCXX/reference-cast.cpp +++ b/clang/test/CodeGenCXX/reference-cast.cpp @@ -3,7 +3,7 @@ // PR6024 extern int i; -// CHECK: define nonnull i32* @_Z16lvalue_noop_castv() [[NUW:#[0-9]+]] +// CHECK: define dereferenceable({{[0-9]+}}) i32* @_Z16lvalue_noop_castv() [[NUW:#[0-9]+]] const int &lvalue_noop_cast() { if (i == 0) // CHECK: store i32 17, i32* @@ -15,7 +15,7 @@ const int &lvalue_noop_cast() { return 17; } -// CHECK-LABEL: define nonnull i16* @_Z20lvalue_integral_castv() +// CHECK-LABEL: define dereferenceable({{[0-9]+}}) i16* @_Z20lvalue_integral_castv() const short &lvalue_integral_cast() { if (i == 0) // CHECK: store i16 17, i16* @@ -27,7 +27,7 @@ const short &lvalue_integral_cast() { return 17; } -// CHECK-LABEL: define nonnull i16* @_Z29lvalue_floating_integral_castv() +// CHECK-LABEL: define dereferenceable({{[0-9]+}}) i16* @_Z29lvalue_floating_integral_castv() const short &lvalue_floating_integral_cast() { if (i == 0) // CHECK: store i16 17, i16* @@ -39,7 +39,7 @@ const short &lvalue_floating_integral_cast() { return 17.5; } -// CHECK-LABEL: define nonnull float* @_Z29lvalue_integral_floating_castv() +// CHECK-LABEL: define dereferenceable({{[0-9]+}}) float* @_Z29lvalue_integral_floating_castv() const float &lvalue_integral_floating_cast() { if (i == 0) // CHECK: store float 1.700000e+{{0*}}1, float* @@ -51,7 +51,7 @@ const float &lvalue_integral_floating_cast() { return 17; } -// CHECK-LABEL: define nonnull float* @_Z20lvalue_floating_castv() +// CHECK-LABEL: define dereferenceable({{[0-9]+}}) float* @_Z20lvalue_floating_castv() const float &lvalue_floating_cast() { if (i == 0) // CHECK: store float 1.700000e+{{0*}}1, float* @@ -65,7 +65,7 @@ const float &lvalue_floating_cast() { int get_int(); -// CHECK-LABEL: define nonnull i8* @_Z24lvalue_integer_bool_castv() +// CHECK-LABEL: define dereferenceable({{[0-9]+}}) i8* @_Z24lvalue_integer_bool_castv() const bool &lvalue_integer_bool_cast() { if (i == 0) // CHECK: call i32 @_Z7get_intv() @@ -82,7 +82,7 @@ const bool &lvalue_integer_bool_cast() { float get_float(); -// CHECK-LABEL: define nonnull i8* @_Z25lvalue_floating_bool_castv() +// CHECK-LABEL: define dereferenceable({{[0-9]+}}) i8* @_Z25lvalue_floating_bool_castv() const bool &lvalue_floating_bool_cast() { if (i == 0) // CHECK: call float @_Z9get_floatv() @@ -107,7 +107,7 @@ typedef int (X::*pmf)(int); pm get_pointer_to_member_data(); pmf get_pointer_to_member_function(); -// CHECK-LABEL: define nonnull i8* @_Z26lvalue_ptrmem_to_bool_castv() +// CHECK-LABEL: define dereferenceable({{[0-9]+}}) i8* @_Z26lvalue_ptrmem_to_bool_castv() const bool &lvalue_ptrmem_to_bool_cast() { if (i == 0) // CHECK: call i64 @_Z26get_pointer_to_member_datav() @@ -125,7 +125,7 @@ const bool &lvalue_ptrmem_to_bool_cast() { return get_pointer_to_member_data(); } -// CHECK-LABEL: define nonnull i8* @_Z27lvalue_ptrmem_to_bool_cast2v +// CHECK-LABEL: define dereferenceable({{[0-9]+}}) i8* @_Z27lvalue_ptrmem_to_bool_cast2v const bool &lvalue_ptrmem_to_bool_cast2() { if (i == 0) // CHECK: {{call.*_Z30get_pointer_to_member_functionv}} |