diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-04-24 02:25:27 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-04-24 02:25:27 +0000 |
| commit | f17fdbd791d78a37cd8f2559247670915d6dcc11 (patch) | |
| tree | 91dfccdbca53bb2136418e80ccb9e3be098be8cf /clang/test/Modules | |
| parent | 807cf41e2f2f22e0b5d2a2fa63ecb0124c8c97b2 (diff) | |
| download | bcm5719-llvm-f17fdbd791d78a37cd8f2559247670915d6dcc11.tar.gz bcm5719-llvm-f17fdbd791d78a37cd8f2559247670915d6dcc11.zip | |
When two templates get merged together, also merge their pattern declarations
together. This is extremely hairy, because in general we need to have loaded
both the template and the pattern before we can determine whether either should
be merged, so we temporarily violate the rule that all merging happens before
reading a decl ends, but *only* in the case where a template's pattern is being
loaded while loading the template itself.
In order to accomodate this for class templates, delay loading the injected
class name type for the pattern of the template until after we've loaded the
template itself, if we happen to load the template first.
llvm-svn: 207063
Diffstat (limited to 'clang/test/Modules')
| -rw-r--r-- | clang/test/Modules/Inputs/templates-left.h | 2 | ||||
| -rw-r--r-- | clang/test/Modules/Inputs/templates-right.h | 2 | ||||
| -rw-r--r-- | clang/test/Modules/cxx-templates.cpp | 12 | ||||
| -rw-r--r-- | clang/test/Modules/templates.mm | 6 |
4 files changed, 12 insertions, 10 deletions
diff --git a/clang/test/Modules/Inputs/templates-left.h b/clang/test/Modules/Inputs/templates-left.h index 99e39bb5431..c61775b14fa 100644 --- a/clang/test/Modules/Inputs/templates-left.h +++ b/clang/test/Modules/Inputs/templates-left.h @@ -39,3 +39,5 @@ int defineListDoubleLeft() { ld.push_back(0.0); return ld.size; } + +template<typename T> struct MergePatternDecl; diff --git a/clang/test/Modules/Inputs/templates-right.h b/clang/test/Modules/Inputs/templates-right.h index 7e18c95bd66..c8056d6539f 100644 --- a/clang/test/Modules/Inputs/templates-right.h +++ b/clang/test/Modules/Inputs/templates-right.h @@ -37,3 +37,5 @@ int defineListDoubleRight() { ld.push_back(0.0); return ld.size; } + +template<typename T> struct MergePatternDecl; diff --git a/clang/test/Modules/cxx-templates.cpp b/clang/test/Modules/cxx-templates.cpp index 291fabf0be5..82ecca31b56 100644 --- a/clang/test/Modules/cxx-templates.cpp +++ b/clang/test/Modules/cxx-templates.cpp @@ -29,8 +29,8 @@ void g() { N::f<double>(1.0); N::f<int>(); N::f(); // expected-error {{no matching function}} - // expected-note@Inputs/cxx-templates-b.h:6 {{couldn't infer template argument}} - // expected-note@Inputs/cxx-templates-b.h:7 {{requires single argument 't'}} + // expected-note@Inputs/cxx-templates-a.h:6 {{couldn't infer template argument}} + // expected-note@Inputs/cxx-templates-a.h:7 {{requires 1 argument}} template_param_kinds_1<0>(); // ok, from cxx-templates-a.h template_param_kinds_1<int>(); // ok, from cxx-templates-b.h @@ -126,20 +126,12 @@ namespace Std { // expected-note@cxx-templates-common.h:21 {{previous}} } -// FIXME: We should only have two entries for each of these names (one for each -// function template), but we don't attempt to deduplicate lookup results from -// sibling modules yet. - // CHECK-GLOBAL: DeclarationName 'f' // CHECK-GLOBAL-NEXT: |-FunctionTemplate {{.*}} 'f' -// CHECK-GLOBAL-NEXT: |-FunctionTemplate {{.*}} 'f' -// CHECK-GLOBAL-NEXT: |-FunctionTemplate {{.*}} 'f' // CHECK-GLOBAL-NEXT: `-FunctionTemplate {{.*}} 'f' // CHECK-NAMESPACE-N: DeclarationName 'f' // CHECK-NAMESPACE-N-NEXT: |-FunctionTemplate {{.*}} 'f' -// CHECK-NAMESPACE-N-NEXT: |-FunctionTemplate {{.*}} 'f' -// CHECK-NAMESPACE-N-NEXT: |-FunctionTemplate {{.*}} 'f' // CHECK-NAMESPACE-N-NEXT: `-FunctionTemplate {{.*}} 'f' // CHECK-DUMP: ClassTemplateDecl {{.*}} <{{.*[/\\]}}cxx-templates-common.h:1:1, {{.*}}> col:{{.*}} in cxx_templates_common SomeTemplate diff --git a/clang/test/Modules/templates.mm b/clang/test/Modules/templates.mm index 0f1bc43e829..fb4303f6a21 100644 --- a/clang/test/Modules/templates.mm +++ b/clang/test/Modules/templates.mm @@ -70,3 +70,9 @@ unsigned testMixedStruct() { // CHECK: load i32* bitcast (i8* getelementptr inbounds (i8* bitcast ({{.*}}* @list_right to i8*), i64 8) to i32*) return list_left.*size_right + list_right.*size_left; } + +template<typename T> struct MergePatternDecl { + typedef int Type; + void f(Type); +}; +template<typename T> void MergePatternDecl<T>::f(Type type) {} |

