diff options
| author | Douglas Gregor <dgregor@apple.com> | 2011-12-22 01:48:48 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2011-12-22 01:48:48 +0000 |
| commit | 022857e03d546ae308fe0d82ce9c64d17de07b32 (patch) | |
| tree | 5cc791a3bf137ef9977241f01e8253e125eeb036 /clang/test | |
| parent | 299cfb7a02a9ee722655a1cc60e6a6af1371e0de (diff) | |
| download | bcm5719-llvm-022857e03d546ae308fe0d82ce9c64d17de07b32.tar.gz bcm5719-llvm-022857e03d546ae308fe0d82ce9c64d17de07b32.zip | |
When deserializing an Objective-C class, check whether we have another
declaration of that same class that either came from some other module
or occurred in the translation unit loading the module. In this case,
we need to merge the two redeclaration chains immediately so that all
such declarations have the same canonical declaration in the resulting
AST (even though they don't in the module files we've imported).
Focusing on Objective-C classes until I'm happy with the design, then
I'll both (1) extend this notion to other kinds of declarations, and
(2) optimize away this extra checking when we're not dealing with
modules. For now, doing this checking for PCH files/preambles gives us
better testing coverage.
llvm-svn: 147123
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/Modules/Inputs/redecl-merge-left.h | 12 | ||||
| -rw-r--r-- | clang/test/Modules/Inputs/redecl-merge-right.h | 9 | ||||
| -rw-r--r-- | clang/test/Modules/redecl-merge.m | 24 |
3 files changed, 45 insertions, 0 deletions
diff --git a/clang/test/Modules/Inputs/redecl-merge-left.h b/clang/test/Modules/Inputs/redecl-merge-left.h index 4e009591de6..7f355e8f9d6 100644 --- a/clang/test/Modules/Inputs/redecl-merge-left.h +++ b/clang/test/Modules/Inputs/redecl-merge-left.h @@ -10,6 +10,18 @@ __import_module__ redecl_merge_top; @class A; +// Test declarations in different modules with no common initial +// declaration. +@class C; +void accept_a_C(C*); + +@class C2; +void accept_a_C2(C2*); + +@class C3; +void accept_a_C3(C3*); +@class C3; + @class Explicit; int *explicit_func(void); diff --git a/clang/test/Modules/Inputs/redecl-merge-right.h b/clang/test/Modules/Inputs/redecl-merge-right.h index 26eed69b91b..f5e4eb8ee44 100644 --- a/clang/test/Modules/Inputs/redecl-merge-right.h +++ b/clang/test/Modules/Inputs/redecl-merge-right.h @@ -9,6 +9,15 @@ __import_module__ redecl_merge_top; @class B; +// Test declarations in different modules with no common initial +// declaration. +@class C; +C *get_a_C(void); +@class C2; +C2 *get_a_C2(void); +@class C3; +C3 *get_a_C3(void); + @class Explicit; int *explicit_func(void); diff --git a/clang/test/Modules/redecl-merge.m b/clang/test/Modules/redecl-merge.m index 7021d14f698..7b06adcce43 100644 --- a/clang/test/Modules/redecl-merge.m +++ b/clang/test/Modules/redecl-merge.m @@ -1,7 +1,13 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -fmodule-cache-path %t -I %S/Inputs %s -verify // RUN: %clang_cc1 -x objective-c++ -fmodule-cache-path %t -I %S/Inputs %s -verify +@class C2; +@class C3; +@class C3; __import_module__ redecl_merge_left; + +@class C3; +@class C3; __import_module__ redecl_merge_right; @implementation A @@ -32,6 +38,23 @@ void testExplicit() { struct explicit_struct es = { 0 }; } +// Test resolution of declarations from multiple modules with no +// common original declaration. +void test_C(C *c) { + c = get_a_C(); + accept_a_C(c); +} + +void test_C2(C2 *c2) { + c2 = get_a_C2(); + accept_a_C2(c2); +} + +void test_C3(C3 *c3) { + c3 = get_a_C3(); + accept_a_C3(c3); +} + __import_module__ redecl_merge_bottom; @implementation B @@ -48,3 +71,4 @@ void testVector() { vec_int.push_back(0); } #endif + |

