diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-05-25 17:16:20 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-05-25 17:16:20 +0000 |
commit | 50df3a02be200a71aac0a680816f26577b46c03e (patch) | |
tree | e359b9dd1f88ba2d3a59a7515733507b998f4119 /clang/test/CodeGenCXX/linkage.cpp | |
parent | 5bed56d2f543da9e5cb0174e60eed0225350a3be (diff) | |
download | bcm5719-llvm-50df3a02be200a71aac0a680816f26577b46c03e.tar.gz bcm5719-llvm-50df3a02be200a71aac0a680816f26577b46c03e.zip |
Fix linkage computation for derived types in inline functions.
John noticed that the fix for pr15930 (r181981) didn't handle indirect
uses of local types. For example, a pointer to local struct, or a
function that returns it.
One way to implement this would be to recursively look for local
types. This would look a lot like the linkage computation itself for
types.
To avoid code duplication and utilize the existing linkage cache, this
patch just makes the computation of "type with no linkage but
externally visible because it is from an inline function" part of the
linkage computation itself.
llvm-svn: 182711
Diffstat (limited to 'clang/test/CodeGenCXX/linkage.cpp')
-rw-r--r-- | clang/test/CodeGenCXX/linkage.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/linkage.cpp b/clang/test/CodeGenCXX/linkage.cpp index ce93161cad5..c803a941614 100644 --- a/clang/test/CodeGenCXX/linkage.cpp +++ b/clang/test/CodeGenCXX/linkage.cpp @@ -103,3 +103,43 @@ namespace test8 { } void *h() { return g(); } } + +namespace test9 { + // CHECK-DAG: define linkonce_odr void @_ZN5test91fIPZNS_1gEvE1S_5EEvT_( + template <typename T> void f(T) {} + inline void *g() { + struct S { + } s; + return reinterpret_cast<void *>(f<S*>); + } + void *h() { return g(); } +} + +namespace test10 { + // CHECK-DAG: define linkonce_odr void @_ZN6test101fIPFZNS_1gEvE1S_6vEEEvT_( + template <typename T> void f(T) {} + inline void *g() { + struct S { + } s; + typedef S(*ftype)(); + return reinterpret_cast<void *>(f<ftype>); + } + void *h() { return g(); } +} + +namespace test11 { + // CHECK-DAG: define internal void @_ZN6test111fIPFZNS_1gEvE1S_7PNS_12_GLOBAL__N_11IEEEEvT_( + namespace { + struct I { + }; + } + + template <typename T> void f(T) {} + inline void *g() { + struct S { + }; + typedef S(*ftype)(I * x); + return reinterpret_cast<void *>(f<ftype>); + } + void *h() { return g(); } +} |