summaryrefslogtreecommitdiffstats
path: root/test/CodeGenCXX/linkage.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-05-25 17:16:20 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-05-25 17:16:20 +0000
commita99ecbcc4c431d52df0b01539035ab5281d54656 (patch)
treed227893f1beb714e47a05479539968da1dee1ee6 /test/CodeGenCXX/linkage.cpp
parent872db39510372c4acd8851a3b956e1a135cfcd41 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182711 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/linkage.cpp')
-rw-r--r--test/CodeGenCXX/linkage.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/CodeGenCXX/linkage.cpp b/test/CodeGenCXX/linkage.cpp
index ce93161cad..c803a94161 100644
--- a/test/CodeGenCXX/linkage.cpp
+++ b/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(); }
+}