Completely re-implement (de-)serialization of declaration
chains. The previous implementation relied heavily on the declaration
chain being stored as a (circular) linked list on disk, as it is in
memory. However, when deserializing from multiple modules, the
different chains could get mixed up, leading to broken declaration chains.
The new solution keeps track of the first and last declarations in the
chain for each module file. When we load a declaration, we search all
of the module files for redeclarations of that declaration, then
splice together all of the lists into a coherent whole (along with any
redeclarations that were actually parsed).
As a drive-by fix, (de-)serialize the redeclaration chains of
TypedefNameDecls, which had somehow gotten missed previously. Add a
test of this serialization.
This new scheme creates a redeclaration table that is fairly large in
the PCH file (on the order of 400k for Cocoa.h's 12MB PCH file). The
table is mmap'd in and searched via a binary search, but it's still
quite large. A future tweak will eliminate entries for declarations
that have no redeclarations anywhere, and should
drastically reduce the size of this table.
llvm-svn: 146841
2011-12-18 07:38:30 +08:00
|
|
|
// RUN: rm -rf %t
|
2015-06-16 08:08:24 +08:00
|
|
|
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -Wreturn-type -fmodules-cache-path=%t -I %S/Inputs %s -verify -Wno-objc-root-class
|
2013-02-18 23:53:43 +08:00
|
|
|
|
2011-12-22 09:48:48 +08:00
|
|
|
@class C2;
|
|
|
|
@class C3;
|
|
|
|
@class C3;
|
2012-12-12 06:11:52 +08:00
|
|
|
@import redecl_merge_left;
|
2012-01-05 09:11:47 +08:00
|
|
|
typedef struct my_struct_type *my_struct_ref;
|
2012-01-02 05:47:52 +08:00
|
|
|
@protocol P4;
|
2011-12-22 09:48:48 +08:00
|
|
|
@class C3;
|
|
|
|
@class C3;
|
2013-02-18 23:53:43 +08:00
|
|
|
|
|
|
|
int *call_eventually_noreturn(void) {
|
|
|
|
eventually_noreturn();
|
|
|
|
} // expected-warning{{control reaches end of non-void function}}
|
|
|
|
|
|
|
|
int *call_eventually_noreturn2(void) {
|
|
|
|
eventually_noreturn2();
|
|
|
|
} // expected-warning{{control reaches end of non-void function}}
|
|
|
|
|
2012-12-12 06:11:52 +08:00
|
|
|
@import redecl_merge_right;
|
Completely re-implement (de-)serialization of declaration
chains. The previous implementation relied heavily on the declaration
chain being stored as a (circular) linked list on disk, as it is in
memory. However, when deserializing from multiple modules, the
different chains could get mixed up, leading to broken declaration chains.
The new solution keeps track of the first and last declarations in the
chain for each module file. When we load a declaration, we search all
of the module files for redeclarations of that declaration, then
splice together all of the lists into a coherent whole (along with any
redeclarations that were actually parsed).
As a drive-by fix, (de-)serialize the redeclaration chains of
TypedefNameDecls, which had somehow gotten missed previously. Add a
test of this serialization.
This new scheme creates a redeclaration table that is fairly large in
the PCH file (on the order of 400k for Cocoa.h's 12MB PCH file). The
table is mmap'd in and searched via a binary search, but it's still
quite large. A future tweak will eliminate entries for declarations
that have no redeclarations anywhere, and should
drastically reduce the size of this table.
llvm-svn: 146841
2011-12-18 07:38:30 +08:00
|
|
|
|
2013-02-18 23:53:43 +08:00
|
|
|
int *call_eventually_noreturn_again(void) {
|
|
|
|
eventually_noreturn();
|
|
|
|
}
|
|
|
|
|
|
|
|
int *call_eventually_noreturn2_again(void) {
|
|
|
|
// noreturn and non-noreturn functions have different types
|
|
|
|
eventually_noreturn2(); // expected-error{{call to 'eventually_noreturn2' is ambiguous}}
|
2013-04-17 16:06:46 +08:00
|
|
|
// expected-note@Inputs/redecl-merge-left.h:93{{candidate function}}
|
|
|
|
// expected-note@Inputs/redecl-merge-right.h:90{{candidate function}}
|
2013-02-18 23:53:43 +08:00
|
|
|
}
|
|
|
|
|
Completely re-implement (de-)serialization of declaration
chains. The previous implementation relied heavily on the declaration
chain being stored as a (circular) linked list on disk, as it is in
memory. However, when deserializing from multiple modules, the
different chains could get mixed up, leading to broken declaration chains.
The new solution keeps track of the first and last declarations in the
chain for each module file. When we load a declaration, we search all
of the module files for redeclarations of that declaration, then
splice together all of the lists into a coherent whole (along with any
redeclarations that were actually parsed).
As a drive-by fix, (de-)serialize the redeclaration chains of
TypedefNameDecls, which had somehow gotten missed previously. Add a
test of this serialization.
This new scheme creates a redeclaration table that is fairly large in
the PCH file (on the order of 400k for Cocoa.h's 12MB PCH file). The
table is mmap'd in and searched via a binary search, but it's still
quite large. A future tweak will eliminate entries for declarations
that have no redeclarations anywhere, and should
drastically reduce the size of this table.
llvm-svn: 146841
2011-12-18 07:38:30 +08:00
|
|
|
@implementation A
|
|
|
|
- (Super*)init { return self; }
|
|
|
|
@end
|
|
|
|
|
|
|
|
void f(A *a) {
|
|
|
|
[a init];
|
|
|
|
}
|
|
|
|
|
|
|
|
@class A;
|
|
|
|
|
2011-12-20 00:14:14 +08:00
|
|
|
B *f1() {
|
|
|
|
return [B create_a_B];
|
|
|
|
}
|
|
|
|
|
2011-12-19 23:27:36 +08:00
|
|
|
@class B;
|
|
|
|
|
2012-01-02 04:30:41 +08:00
|
|
|
void testProtoMerge(id<P1> p1, id<P2> p2) {
|
|
|
|
[p1 protoMethod1];
|
|
|
|
[p2 protoMethod2];
|
|
|
|
}
|
|
|
|
|
2012-01-04 06:46:00 +08:00
|
|
|
struct S1 {
|
|
|
|
int s1_field;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct S3 {
|
|
|
|
int s3_field;
|
|
|
|
};
|
|
|
|
|
|
|
|
void testTagMerge() {
|
|
|
|
consume_S1(produce_S1());
|
|
|
|
struct S2 s2;
|
|
|
|
s2.field = 0;
|
|
|
|
consume_S2(produce_S2());
|
|
|
|
struct S1 s1;
|
|
|
|
s1.s1_field = 0;
|
|
|
|
consume_S3(produce_S3());
|
|
|
|
struct S4 s4;
|
|
|
|
s4.field = 0;
|
|
|
|
consume_S4(produce_S4());
|
|
|
|
struct S3 s3;
|
|
|
|
s3.s3_field = 0;
|
|
|
|
}
|
|
|
|
|
2012-01-04 07:26:26 +08:00
|
|
|
void testTypedefMerge(int i, double d) {
|
|
|
|
T1 *ip = &i;
|
|
|
|
// FIXME: Typedefs aren't actually merged in the sense of other merges, because
|
|
|
|
// we should only merge them when the types are identical.
|
2013-04-17 16:06:46 +08:00
|
|
|
// expected-note@Inputs/redecl-merge-left.h:60{{candidate found by name lookup is 'T2'}}
|
|
|
|
// expected-note@Inputs/redecl-merge-right.h:63{{candidate found by name lookup is 'T2'}}
|
2012-01-04 07:26:26 +08:00
|
|
|
T2 *dp = &d; // expected-error{{reference to 'T2' is ambiguous}}
|
|
|
|
}
|
|
|
|
|
Implement declaration merging for non-template functions from
different modules. This implementation is a first approximation of
what we want, using only the function type to determine
equivalence. Later, we'll want to deal with some of the more subtle
issues, including:
- C allows a prototyped declaration and a non-prototyped declaration
to be merged, which we should support
- We may want to ignore the return type when merging, then
complain if the return types differ. Or, we may want to leave it
as it us, so that we only complain if overload resolution
eventually fails.
- C++ non-static member functions need to consider cv-qualifiers
and ref-qualifiers.
- Function templates need to consider the template parameters and
return type.
- Function template specializations will have special rules.
- We can now (accidentally!) end up overloading in C, even without
the "overloadable" attribute, and will need to detect this at some
point.
The actual detection of "is this an overload?" is implemented by
Sema::IsOverload(), which will need to be moved into the AST library
for re-use here. That will be a future refactor.
llvm-svn: 147534
2012-01-05 01:13:46 +08:00
|
|
|
void testFuncMerge(int i) {
|
|
|
|
func0(i);
|
|
|
|
func1(i);
|
2013-04-17 16:06:46 +08:00
|
|
|
// expected-note@Inputs/redecl-merge-left.h:64{{candidate function}}
|
|
|
|
// expected-note@Inputs/redecl-merge-right.h:70{{candidate function}}
|
Implement declaration merging for non-template functions from
different modules. This implementation is a first approximation of
what we want, using only the function type to determine
equivalence. Later, we'll want to deal with some of the more subtle
issues, including:
- C allows a prototyped declaration and a non-prototyped declaration
to be merged, which we should support
- We may want to ignore the return type when merging, then
complain if the return types differ. Or, we may want to leave it
as it us, so that we only complain if overload resolution
eventually fails.
- C++ non-static member functions need to consider cv-qualifiers
and ref-qualifiers.
- Function templates need to consider the template parameters and
return type.
- Function template specializations will have special rules.
- We can now (accidentally!) end up overloading in C, even without
the "overloadable" attribute, and will need to detect this at some
point.
The actual detection of "is this an overload?" is implemented by
Sema::IsOverload(), which will need to be moved into the AST library
for re-use here. That will be a future refactor.
llvm-svn: 147534
2012-01-05 01:13:46 +08:00
|
|
|
func2(i); // expected-error{{call to 'func2' is ambiguous}}
|
|
|
|
}
|
|
|
|
|
2012-01-05 01:21:36 +08:00
|
|
|
void testVarMerge(int i) {
|
|
|
|
var1 = i;
|
2013-04-17 16:06:46 +08:00
|
|
|
// expected-note@Inputs/redecl-merge-left.h:77{{candidate found by name lookup is 'var2'}}
|
|
|
|
// expected-note@Inputs/redecl-merge-right.h:77{{candidate found by name lookup is 'var2'}}
|
2012-01-05 01:21:36 +08:00
|
|
|
var2 = i; // expected-error{{reference to 'var2' is ambiguous}}
|
2013-04-17 16:06:46 +08:00
|
|
|
// expected-note@Inputs/redecl-merge-left.h:79{{candidate found by name lookup is 'var3'}}
|
|
|
|
// expected-note@Inputs/redecl-merge-right.h:79{{candidate found by name lookup is 'var3'}}
|
2012-01-05 01:21:36 +08:00
|
|
|
var3 = i; // expected-error{{reference to 'var3' is ambiguous}}
|
|
|
|
}
|
|
|
|
|
2011-12-21 02:11:52 +08:00
|
|
|
// Test redeclarations of entities in explicit submodules, to make
|
|
|
|
// sure we're maintaining the declaration chains even when normal name
|
|
|
|
// lookup can't see what we're looking for.
|
|
|
|
void testExplicit() {
|
|
|
|
Explicit *e;
|
|
|
|
int *(*fp)(void) = &explicit_func;
|
|
|
|
int *ip = explicit_func();
|
|
|
|
|
|
|
|
// FIXME: Should complain about definition not having been imported.
|
|
|
|
struct explicit_struct es = { 0 };
|
|
|
|
}
|
|
|
|
|
2011-12-22 09:48:48 +08:00
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
|
2011-12-23 03:44:59 +08:00
|
|
|
C4 *global_C4;
|
2012-01-16 02:08:05 +08:00
|
|
|
|
|
|
|
ClassWithDef *cwd1;
|
|
|
|
|
2012-12-12 06:11:52 +08:00
|
|
|
@import redecl_merge_left_left;
|
2011-12-23 03:44:59 +08:00
|
|
|
|
2011-12-23 05:40:42 +08:00
|
|
|
void test_C4a(C4 *c4) {
|
2011-12-23 03:44:59 +08:00
|
|
|
global_C4 = c4 = get_a_C4();
|
|
|
|
accept_a_C4(c4);
|
|
|
|
}
|
|
|
|
|
2012-01-16 02:08:05 +08:00
|
|
|
void test_ClassWithDef(ClassWithDef *cwd) {
|
|
|
|
[cwd method];
|
|
|
|
}
|
|
|
|
|
2012-12-12 06:11:52 +08:00
|
|
|
@import redecl_merge_bottom;
|
Completely re-implement (de-)serialization of declaration
chains. The previous implementation relied heavily on the declaration
chain being stored as a (circular) linked list on disk, as it is in
memory. However, when deserializing from multiple modules, the
different chains could get mixed up, leading to broken declaration chains.
The new solution keeps track of the first and last declarations in the
chain for each module file. When we load a declaration, we search all
of the module files for redeclarations of that declaration, then
splice together all of the lists into a coherent whole (along with any
redeclarations that were actually parsed).
As a drive-by fix, (de-)serialize the redeclaration chains of
TypedefNameDecls, which had somehow gotten missed previously. Add a
test of this serialization.
This new scheme creates a redeclaration table that is fairly large in
the PCH file (on the order of 400k for Cocoa.h's 12MB PCH file). The
table is mmap'd in and searched via a binary search, but it's still
quite large. A future tweak will eliminate entries for declarations
that have no redeclarations anywhere, and should
drastically reduce the size of this table.
llvm-svn: 146841
2011-12-18 07:38:30 +08:00
|
|
|
|
2011-12-23 05:40:42 +08:00
|
|
|
void test_C4b() {
|
|
|
|
if (&refers_to_C4) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-19 23:27:36 +08:00
|
|
|
@implementation B
|
2011-12-20 00:14:14 +08:00
|
|
|
+ (B*)create_a_B { return 0; }
|
2011-12-19 23:27:36 +08:00
|
|
|
@end
|
|
|
|
|
Completely re-implement (de-)serialization of declaration
chains. The previous implementation relied heavily on the declaration
chain being stored as a (circular) linked list on disk, as it is in
memory. However, when deserializing from multiple modules, the
different chains could get mixed up, leading to broken declaration chains.
The new solution keeps track of the first and last declarations in the
chain for each module file. When we load a declaration, we search all
of the module files for redeclarations of that declaration, then
splice together all of the lists into a coherent whole (along with any
redeclarations that were actually parsed).
As a drive-by fix, (de-)serialize the redeclaration chains of
TypedefNameDecls, which had somehow gotten missed previously. Add a
test of this serialization.
This new scheme creates a redeclaration table that is fairly large in
the PCH file (on the order of 400k for Cocoa.h's 12MB PCH file). The
table is mmap'd in and searched via a binary search, but it's still
quite large. A future tweak will eliminate entries for declarations
that have no redeclarations anywhere, and should
drastically reduce the size of this table.
llvm-svn: 146841
2011-12-18 07:38:30 +08:00
|
|
|
void g(A *a) {
|
|
|
|
[a init];
|
|
|
|
}
|
2011-12-20 02:19:24 +08:00
|
|
|
|
2012-01-02 05:47:52 +08:00
|
|
|
@protocol P3
|
|
|
|
- (void)p3_method;
|
|
|
|
@end
|
|
|
|
|
|
|
|
id<P4> p4;
|
|
|
|
id<P3> p3;
|
|
|
|
|
2012-01-14 07:49:34 +08:00
|
|
|
// Make sure we don't get conflicts with 'id'.
|
|
|
|
funcptr_with_id fid;
|
|
|
|
id id_global;
|
2013-02-18 23:53:43 +08:00
|
|
|
|
|
|
|
|