Implement cross-module declaration merging for tag declarations, so
that if two modules A and B both contain a declaration of a tag such
as
struct X;
and those two modules are unrelated, the two declarations of X will be
merged into a single redeclaration chain.
llvm-svn: 147488
diff --git a/clang/test/Modules/Inputs/redecl-merge-bottom.h b/clang/test/Modules/Inputs/redecl-merge-bottom.h
index a054cd2..4e52a67 100644
--- a/clang/test/Modules/Inputs/redecl-merge-bottom.h
+++ b/clang/test/Modules/Inputs/redecl-merge-bottom.h
@@ -13,6 +13,9 @@
@protocol P1;
+struct S1;
+struct S3;
+
void refers_to_C4(C4*);
#ifdef __cplusplus
diff --git a/clang/test/Modules/Inputs/redecl-merge-left.h b/clang/test/Modules/Inputs/redecl-merge-left.h
index 82146f7..b21271b 100644
--- a/clang/test/Modules/Inputs/redecl-merge-left.h
+++ b/clang/test/Modules/Inputs/redecl-merge-left.h
@@ -15,6 +15,14 @@
- (void)protoMethod2;
@end
+struct S1;
+struct S2 {
+ int field;
+};
+
+struct S1 *produce_S1(void);
+void consume_S2(struct S2*);
+
// Test declarations in different modules with no common initial
// declaration.
@class C;
@@ -39,6 +47,15 @@
@protocol P3;
+struct S3;
+struct S3;
+struct S4 {
+ int field;
+};
+
+struct S3 *produce_S3(void);
+void consume_S4(struct S4*);
+
#ifdef __cplusplus
template<typename T> class Vector;
diff --git a/clang/test/Modules/Inputs/redecl-merge-right.h b/clang/test/Modules/Inputs/redecl-merge-right.h
index b6dfe2f..686a962 100644
--- a/clang/test/Modules/Inputs/redecl-merge-right.h
+++ b/clang/test/Modules/Inputs/redecl-merge-right.h
@@ -21,6 +21,12 @@
@protocol P2;
+struct S1;
+struct S2;
+
+void consume_S1(struct S1*);
+struct S2 *produce_S2(void);
+
// Test declarations in different modules with no common initial
// declaration.
@class C;
@@ -47,6 +53,12 @@
@protocol P3;
@protocol P3;
+struct S3;
+struct S4;
+
+void consume_S3(struct S3*);
+struct S4 *produce_S4(void);
+
#ifdef __cplusplus
template<typename T> class Vector {
public:
diff --git a/clang/test/Modules/Inputs/redecl-merge-top.h b/clang/test/Modules/Inputs/redecl-merge-top.h
index 64c0c92..519254c 100644
--- a/clang/test/Modules/Inputs/redecl-merge-top.h
+++ b/clang/test/Modules/Inputs/redecl-merge-top.h
@@ -11,6 +11,10 @@
@protocol P2;
@protocol P2;
+struct S1;
+struct S2;
+struct S2;
+
#ifdef __cplusplus
template<typename T> class Vector;
#endif
diff --git a/clang/test/Modules/redecl-merge.m b/clang/test/Modules/redecl-merge.m
index dfbc25f..c0e83e8 100644
--- a/clang/test/Modules/redecl-merge.m
+++ b/clang/test/Modules/redecl-merge.m
@@ -32,6 +32,29 @@
[p2 protoMethod2];
}
+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;
+}
+
// 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.