2012-01-04 02:04:46 +08:00
|
|
|
@import redecl_merge_top;
|
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
|
|
|
|
|
|
|
@interface Super
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface A : Super
|
|
|
|
- (Super*)init;
|
|
|
|
@end
|
|
|
|
|
2011-12-19 23:27:36 +08:00
|
|
|
@class B;
|
|
|
|
|
2012-01-02 04:30:41 +08:00
|
|
|
@protocol P1
|
|
|
|
- (void)protoMethod1;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@protocol P1;
|
|
|
|
|
|
|
|
@protocol P2;
|
|
|
|
|
|
|
|
@protocol P2;
|
|
|
|
|
|
|
|
@protocol P2;
|
|
|
|
|
2012-01-04 06:46:00 +08:00
|
|
|
struct S1;
|
|
|
|
struct S2;
|
|
|
|
|
|
|
|
void consume_S1(struct S1*);
|
|
|
|
struct S2 *produce_S2(void);
|
|
|
|
|
2011-12-22 09:48:48 +08:00
|
|
|
// 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);
|
|
|
|
|
2011-12-23 03:44:59 +08:00
|
|
|
@class C4;
|
|
|
|
@class C4;
|
|
|
|
@class C4;
|
|
|
|
@class C4;
|
|
|
|
C4 *get_a_C4(void);
|
|
|
|
|
2011-12-21 02:11:52 +08:00
|
|
|
@class Explicit;
|
|
|
|
|
|
|
|
int *explicit_func(void);
|
|
|
|
|
|
|
|
struct explicit_struct;
|
|
|
|
|
2012-01-02 05:47:52 +08:00
|
|
|
@protocol P4, P3;
|
|
|
|
@protocol P3;
|
|
|
|
@protocol P3;
|
|
|
|
@protocol P3;
|
|
|
|
|
2012-01-04 06:46:00 +08:00
|
|
|
struct S3;
|
|
|
|
struct S4;
|
|
|
|
|
|
|
|
void consume_S3(struct S3*);
|
|
|
|
struct S4 *produce_S4(void);
|
|
|
|
|
2012-01-04 07:26:26 +08:00
|
|
|
typedef int T1;
|
|
|
|
typedef double T2;
|
|
|
|
|
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
|
|
|
int func0(int);
|
|
|
|
int func1(int);
|
|
|
|
int func1(int);
|
|
|
|
int func1(int);
|
|
|
|
int func1(int);
|
|
|
|
static int func2(int);
|
|
|
|
|
2012-01-05 01:21:36 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Spacing matters!
|
|
|
|
extern int var1;
|
|
|
|
extern int var2;
|
|
|
|
|
|
|
|
static double var3;
|
|
|
|
|
2011-12-20 02:19:24 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
template<typename T> class Vector {
|
|
|
|
public:
|
|
|
|
void push_back(const T&);
|
|
|
|
};
|
|
|
|
#endif
|
2011-12-21 06:06:13 +08:00
|
|
|
|
|
|
|
int ONE;
|
2012-01-04 02:04:46 +08:00
|
|
|
@import redecl_merge_top.Explicit;
|
2011-12-21 06:06:13 +08:00
|
|
|
const int one = ONE;
|