summaryrefslogtreecommitdiff
path: root/clang/test/ASTMerge
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/ASTMerge')
-rw-r--r--clang/test/ASTMerge/Inputs/category1.m48
-rw-r--r--clang/test/ASTMerge/Inputs/category2.m49
-rw-r--r--clang/test/ASTMerge/Inputs/class-template1.cpp34
-rw-r--r--clang/test/ASTMerge/Inputs/class-template2.cpp35
-rw-r--r--clang/test/ASTMerge/Inputs/class1.cpp15
-rw-r--r--clang/test/ASTMerge/Inputs/class2.cpp9
-rw-r--r--clang/test/ASTMerge/Inputs/enum1.c42
-rw-r--r--clang/test/ASTMerge/Inputs/enum2.c42
-rw-r--r--clang/test/ASTMerge/Inputs/exprs1.c10
-rw-r--r--clang/test/ASTMerge/Inputs/exprs2.c10
-rw-r--r--clang/test/ASTMerge/Inputs/function1.c6
-rw-r--r--clang/test/ASTMerge/Inputs/function2.c7
-rw-r--r--clang/test/ASTMerge/Inputs/interface1.m103
-rw-r--r--clang/test/ASTMerge/Inputs/interface2.m100
-rw-r--r--clang/test/ASTMerge/Inputs/lit.local.cfg1
-rw-r--r--clang/test/ASTMerge/Inputs/namespace1.cpp17
-rw-r--r--clang/test/ASTMerge/Inputs/namespace2.cpp17
-rw-r--r--clang/test/ASTMerge/Inputs/property1.m31
-rw-r--r--clang/test/ASTMerge/Inputs/property2.m33
-rw-r--r--clang/test/ASTMerge/Inputs/struct1.c63
-rw-r--r--clang/test/ASTMerge/Inputs/struct2.c60
-rw-r--r--clang/test/ASTMerge/Inputs/typedef1.c4
-rw-r--r--clang/test/ASTMerge/Inputs/typedef2.c4
-rw-r--r--clang/test/ASTMerge/Inputs/var1.c7
-rw-r--r--clang/test/ASTMerge/Inputs/var1.h1
-rw-r--r--clang/test/ASTMerge/Inputs/var2.c7
-rw-r--r--clang/test/ASTMerge/category.m11
-rw-r--r--clang/test/ASTMerge/class-template.cpp24
-rw-r--r--clang/test/ASTMerge/class.cpp9
-rw-r--r--clang/test/ASTMerge/enum.c25
-rw-r--r--clang/test/ASTMerge/exprs.c4
-rw-r--r--clang/test/ASTMerge/function.c9
-rw-r--r--clang/test/ASTMerge/interface.m22
-rw-r--r--clang/test/ASTMerge/namespace.cpp6
-rw-r--r--clang/test/ASTMerge/property.m13
-rw-r--r--clang/test/ASTMerge/struct.c42
-rw-r--r--clang/test/ASTMerge/typedef.c7
-rw-r--r--clang/test/ASTMerge/var.c12
38 files changed, 939 insertions, 0 deletions
diff --git a/clang/test/ASTMerge/Inputs/category1.m b/clang/test/ASTMerge/Inputs/category1.m
new file mode 100644
index 0000000..afcaab8
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/category1.m
@@ -0,0 +1,48 @@
+@interface I1
+@end
+
+// Matching category
+@interface I1 (Cat1)
+- (int)method0;
+@end
+
+// Matching class extension
+@interface I1 ()
+- (int)method1;
+@end
+
+// Mismatched category
+@interface I1 (Cat2)
+- (int)method2;
+@end
+
+@interface I2
+@end
+
+// Mismatched class extension
+@interface I2 ()
+- (int)method3;
+@end
+
+// Category with implementation
+@interface I2 (Cat3)
+@end
+
+@implementation I2 (Cat3)
+@end
+
+// Category with implementation
+@interface I2 (Cat4)
+@end
+
+@implementation I2 (Cat4)
+@end
+
+// Category with mismatched implementation
+@interface I2 (Cat6)
+@end
+
+@implementation I2 (Cat6)
+- (float)blah { return 0; }
+@end
+
diff --git a/clang/test/ASTMerge/Inputs/category2.m b/clang/test/ASTMerge/Inputs/category2.m
new file mode 100644
index 0000000..49a3c27
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/category2.m
@@ -0,0 +1,49 @@
+typedef int Int;
+
+@interface I1
+@end
+
+// Matching category
+@interface I1 (Cat1)
+- (Int)method0;
+@end
+
+// Matching class extension
+@interface I1 ()
+- (Int)method1;
+@end
+
+// Mismatched category
+@interface I1 (Cat2)
+- (float)method2;
+@end
+
+@interface I2
+@end
+
+// Mismatched class extension
+@interface I2 ()
+- (float)method3;
+@end
+
+// Category with implementation
+@interface I2 (Cat3)
+@end
+
+@implementation I2 (Cat3)
+@end
+
+// Category with implementation
+@interface I2 (Cat5)
+@end
+
+@implementation I2 (Cat5)
+@end
+
+// Category with mismatched implementation
+@interface I2 (Cat6)
+@end
+
+@implementation I2 (Cat6)
+- (int)blah { return 0; }
+@end
diff --git a/clang/test/ASTMerge/Inputs/class-template1.cpp b/clang/test/ASTMerge/Inputs/class-template1.cpp
new file mode 100644
index 0000000..440b5ab
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/class-template1.cpp
@@ -0,0 +1,34 @@
+template<typename T>
+struct X0;
+
+template<int I>
+struct X1;
+
+template<int I>
+struct X2;
+
+template<int I>
+struct X3;
+
+template<template<int I> class>
+struct X4;
+
+template<template<long> class>
+struct X5;
+
+template<typename>
+struct X6;
+
+extern X0<int> *x0i;
+extern X0<long> *x0l;
+extern X0<float> *x0r;
+
+template<>
+struct X0<char> {
+ int member;
+};
+
+template<>
+struct X0<wchar_t> {
+ int member;
+};
diff --git a/clang/test/ASTMerge/Inputs/class-template2.cpp b/clang/test/ASTMerge/Inputs/class-template2.cpp
new file mode 100644
index 0000000..6300301
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/class-template2.cpp
@@ -0,0 +1,35 @@
+template<class T>
+struct X0;
+
+template<int I>
+struct X1;
+
+template<long I>
+struct X2;
+
+template<typename>
+struct X3;
+
+template<template<int I> class>
+struct X4;
+
+template<template<int I> class>
+struct X5;
+
+template<template<int I> class>
+struct X6;
+
+typedef int Integer;
+extern X0<Integer> *x0i;
+extern X0<float> *x0f;
+extern X0<double> *x0r;
+
+template<>
+struct X0<char> {
+ int member;
+};
+
+template<>
+struct X0<wchar_t> {
+ float member;
+};
diff --git a/clang/test/ASTMerge/Inputs/class1.cpp b/clang/test/ASTMerge/Inputs/class1.cpp
new file mode 100644
index 0000000..b600cdb
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/class1.cpp
@@ -0,0 +1,15 @@
+struct A {
+ int x;
+};
+
+struct B : A {
+ float y;
+ float foo();
+};
+
+struct C {
+ C(int i = 10);
+ C(const C&);
+ C &operator=(C&);
+ ~C();
+};
diff --git a/clang/test/ASTMerge/Inputs/class2.cpp b/clang/test/ASTMerge/Inputs/class2.cpp
new file mode 100644
index 0000000..fa38916
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/class2.cpp
@@ -0,0 +1,9 @@
+struct A {
+ int x;
+};
+
+struct B : A {
+ int y;
+ int foo();
+};
+
diff --git a/clang/test/ASTMerge/Inputs/enum1.c b/clang/test/ASTMerge/Inputs/enum1.c
new file mode 100644
index 0000000..f2b9c5c
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/enum1.c
@@ -0,0 +1,42 @@
+// Matching
+enum E1 {
+ E1Enumerator1,
+ E1Enumerator2 = 3,
+ E1Enumerator3
+} x1;
+
+// Value mismatch
+enum E2 {
+ E2Enumerator1,
+ E2Enumerator2 = 3,
+ E2Enumerator3
+} x2;
+
+// Name mismatch
+enum E3 {
+ E3Enumerator1,
+ E3Enumerator2 = 3,
+ E3Enumerator3
+} x3;
+
+// Missing enumerator
+enum E4 {
+ E4Enumerator1,
+ E4Enumerator2,
+ E4Enumerator3
+} x4;
+
+// Extra enumerator
+enum E5 {
+ E5Enumerator1,
+ E5Enumerator2,
+ E5Enumerator3
+} x5;
+
+// Matching, with typedef
+typedef enum {
+ E6Enumerator1,
+ E6Enumerator2
+} E6;
+
+E6 x6;
diff --git a/clang/test/ASTMerge/Inputs/enum2.c b/clang/test/ASTMerge/Inputs/enum2.c
new file mode 100644
index 0000000..315b4dc
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/enum2.c
@@ -0,0 +1,42 @@
+// Matching
+enum E1 {
+ E1Enumerator1,
+ E1Enumerator2 = 3,
+ E1Enumerator3
+} x1;
+
+// Value mismatch
+enum E2 {
+ E2Enumerator1,
+ E2Enumerator2 = 4,
+ E2Enumerator3
+} x2;
+
+// Name mismatch
+enum E3 {
+ E3Enumerator1,
+ E3Enumerator = 3,
+ E3Enumerator3
+} x3;
+
+// Missing enumerator
+enum E4 {
+ E4Enumerator1,
+ E4Enumerator2
+} x4;
+
+// Extra enumerator
+enum E5 {
+ E5Enumerator1,
+ E5Enumerator2,
+ E5Enumerator3,
+ E5Enumerator4
+} x5;
+
+// Matching, with typedef
+typedef enum {
+ E6Enumerator1,
+ E6Enumerator2
+} E6;
+
+E6 x6;
diff --git a/clang/test/ASTMerge/Inputs/exprs1.c b/clang/test/ASTMerge/Inputs/exprs1.c
new file mode 100644
index 0000000..1c268da
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/exprs1.c
@@ -0,0 +1,10 @@
+// Matching
+enum E0 {
+ E0_Val0 = 'a',
+ E0_Val1 = (17),
+ E0_Val2 = (1 << 2),
+ E0_Val3 = E0_Val2,
+ E0_Val4 = sizeof(int*),
+ E0_Val5 = (unsigned int)-1
+};
+
diff --git a/clang/test/ASTMerge/Inputs/exprs2.c b/clang/test/ASTMerge/Inputs/exprs2.c
new file mode 100644
index 0000000..1c268da
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/exprs2.c
@@ -0,0 +1,10 @@
+// Matching
+enum E0 {
+ E0_Val0 = 'a',
+ E0_Val1 = (17),
+ E0_Val2 = (1 << 2),
+ E0_Val3 = E0_Val2,
+ E0_Val4 = sizeof(int*),
+ E0_Val5 = (unsigned int)-1
+};
+
diff --git a/clang/test/ASTMerge/Inputs/function1.c b/clang/test/ASTMerge/Inputs/function1.c
new file mode 100644
index 0000000..4523bd3
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/function1.c
@@ -0,0 +1,6 @@
+void f0(int);
+void f1(int, float);
+void f2();
+void f3(void);
+void f4(int, int);
+int f5(int) __attribute__((const));
diff --git a/clang/test/ASTMerge/Inputs/function2.c b/clang/test/ASTMerge/Inputs/function2.c
new file mode 100644
index 0000000..6ca810a
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/function2.c
@@ -0,0 +1,7 @@
+typedef int Int;
+void f0(Int);
+void f1(Int, double);
+void f2(int, int);
+void f3(int);
+static void f4(float, float);
+int f5(int) __attribute__((const));
diff --git a/clang/test/ASTMerge/Inputs/interface1.m b/clang/test/ASTMerge/Inputs/interface1.m
new file mode 100644
index 0000000..5865c0e
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/interface1.m
@@ -0,0 +1,103 @@
+// Matches
+@interface I1 {
+ int ivar1;
+}
+@end
+
+// Matches
+@interface I2 : I1 {
+ float ivar2;
+}
+@end
+
+// Ivar mismatch
+@interface I3 {
+ int ivar1;
+ int ivar2;
+}
+@end
+
+// Superclass mismatch
+@interface I4 : I2 {
+}
+@end
+
+// Methods match
+@interface I5
+- (int)foo;
++ (float)bar;
+@end
+
+// Method mismatch
+@interface I6
+- (int)foo;
++ (int)foo;
+@end
+
+// Method mismatch
+@interface I7
+- (int)foo;
++ (int)bar:(int)x;
+@end
+
+// Method mismatch
+@interface I8
+- (int)foo;
++ (int)bar:(float)x;
+@end
+
+// Matching protocol
+@protocol P0
++ (int)foo;
+- (int)bar:(float)x;
+@end
+
+// Protocol with mismatching method
+@protocol P1
++ (int)foo;
+- (int)bar:(float)x;
+@end
+
+// Interface with protocol
+@interface I9 <P0>
++ (int)foo;
+- (int)bar:(float)x;
+@end
+
+// Protocol with protocol
+@protocol P2 <P0>
+- (float)wibble:(int)a1 second:(int)a2;
+@end
+
+// Forward-declared interfaces
+@class I10, I11;
+@interface I12
+@end
+
+// Forward-declared protocols
+@protocol P3, P5;
+@protocol P4
+- (double)honk:(int)a;
+@end
+
+// Interface with implementation
+@interface I13
+@end
+
+@implementation I13
+@end
+
+@interface I13a
+@end
+
+@implementation I13a
+@end
+
+// Implementation by itself
+@implementation I14 : I12
+@end
+
+@implementation I15 : I12
+@end
+
+
diff --git a/clang/test/ASTMerge/Inputs/interface2.m b/clang/test/ASTMerge/Inputs/interface2.m
new file mode 100644
index 0000000..2133bd1
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/interface2.m
@@ -0,0 +1,100 @@
+// Matches
+@interface I1 {
+ int ivar1;
+}
+@end
+
+// Matches
+@interface I2 : I1 {
+ float ivar2;
+}
+@end
+
+// Ivar mismatch
+@interface I3 {
+ int ivar1;
+ float ivar2;
+}
+@end
+
+// Superclass mismatch
+@interface I4 : I1 {
+}
+@end
+
+// Methods match
+@interface I5
++ (float)bar;
+- (int)foo;
+@end
+
+// Method mismatch
+@interface I6
++ (float)foo;
+@end
+
+// Method mismatch
+@interface I7
+- (int)foo;
++ (int)bar:(float)x;
+@end
+
+// Method mismatch
+@interface I8
+- (int)foo;
++ (int)bar:(float)x, ...;
+@end
+
+// Matching protocol
+@protocol P0
++ (int)foo;
+- (int)bar:(float)x;
+@end
+
+// Protocol with mismatching method
+@protocol P1
++ (int)foo;
+- (int)bar:(double)x;
+@end
+
+// Interface with protocol
+@interface I9 <P0>
++ (int)foo;
+- (int)bar:(float)x;
+@end
+
+// Protocol with protocol
+@protocol P2 <P0>
+- (float)wibble:(int)a1 second:(int)a2;
+@end
+
+// Forward-declared interface
+@class I10; @interface I12 @end
+@interface I11
+@end
+
+// Forward-declared protocols
+@protocol P3, P4;
+@protocol P5
+- (double)honk:(int)a;
+@end
+
+// Interface with implementation
+@interface I13
+@end
+
+@implementation I13
+@end
+
+@interface I13b
+@end
+
+@implementation I13b
+@end
+
+// Implementation by itself
+@implementation I14 : I12
+@end
+
+@implementation I15 : I11
+@end
diff --git a/clang/test/ASTMerge/Inputs/lit.local.cfg b/clang/test/ASTMerge/Inputs/lit.local.cfg
new file mode 100644
index 0000000..e6f55ee
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/lit.local.cfg
@@ -0,0 +1 @@
+config.suffixes = []
diff --git a/clang/test/ASTMerge/Inputs/namespace1.cpp b/clang/test/ASTMerge/Inputs/namespace1.cpp
new file mode 100644
index 0000000..1ff84f3
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/namespace1.cpp
@@ -0,0 +1,17 @@
+// Merge success
+namespace N1 {
+ int x;
+}
+
+// Merge multiple namespaces
+namespace N2 {
+ extern int x;
+}
+namespace N2 {
+ extern float y;
+}
+
+// Merge namespace with conflict
+namespace N3 {
+ extern float z;
+}
diff --git a/clang/test/ASTMerge/Inputs/namespace2.cpp b/clang/test/ASTMerge/Inputs/namespace2.cpp
new file mode 100644
index 0000000..80429f7
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/namespace2.cpp
@@ -0,0 +1,17 @@
+// Merge success
+namespace N1 {
+ extern int x0;
+}
+
+// Merge multiple namespaces
+namespace N2 {
+ extern int x;
+}
+namespace N2 {
+ extern float y;
+}
+
+// Merge namespace with conflict
+namespace N3 {
+ extern double z;
+}
diff --git a/clang/test/ASTMerge/Inputs/property1.m b/clang/test/ASTMerge/Inputs/property1.m
new file mode 100644
index 0000000..22fe0a0
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/property1.m
@@ -0,0 +1,31 @@
+// Matching properties
+@interface I1 {
+}
+- (int)getProp2;
+- (void)setProp2:(int)value;
+@end
+
+// Mismatched property
+@interface I2
+@property (readonly) float Prop1;
+@end
+
+// Properties with implementations
+@interface I3 {
+ int ivar1;
+ int ivar2;
+ int ivar3;
+ int Prop4;
+}
+@property int Prop1;
+@property int Prop2;
+@property int Prop3;
+@property int Prop4;
+@end
+
+@implementation I3
+@synthesize Prop1 = ivar1;
+@synthesize Prop2 = ivar3;
+@dynamic Prop3;
+@synthesize Prop4;
+@end
diff --git a/clang/test/ASTMerge/Inputs/property2.m b/clang/test/ASTMerge/Inputs/property2.m
new file mode 100644
index 0000000..64a03fb
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/property2.m
@@ -0,0 +1,33 @@
+// Matching properties
+@interface I1 {
+}
+- (int)getProp2;
+- (void)setProp2:(int)value;
+@property (readonly) int Prop1;
+@property (getter = getProp2, setter = setProp2:) int Prop2;
+@end
+
+// Mismatched property
+@interface I2
+@property (readonly) int Prop1;
+@end
+
+// Properties with implementations
+@interface I3 {
+ int ivar1;
+ int ivar2;
+ int ivar3;
+ int Prop4;
+}
+@property int Prop1;
+@property int Prop2;
+@property int Prop3;
+@property int Prop4;
+@end
+
+@implementation I3
+@synthesize Prop2 = ivar2;
+@synthesize Prop1 = ivar1;
+@synthesize Prop3 = ivar3;
+@synthesize Prop4 = Prop4;
+@end
diff --git a/clang/test/ASTMerge/Inputs/struct1.c b/clang/test/ASTMerge/Inputs/struct1.c
new file mode 100644
index 0000000..af2af8a
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/struct1.c
@@ -0,0 +1,63 @@
+typedef int Int;
+typedef float Float;
+
+// Matches
+struct S0 {
+ Int field1;
+ Float field2;
+};
+
+struct S0 x0;
+
+// Mismatch in field type
+struct S1 {
+ Int field1;
+ int field2;
+};
+
+struct S1 x1;
+
+// Mismatch in tag kind.
+struct S2 { int i; float f; } x2;
+
+// Missing fields
+struct S3 { int i; float f; double d; } x3;
+
+// Extra fields
+struct S4 { int i; } x4;
+
+// Bit-field matches
+struct S5 { int i : 8; unsigned j : 8; } x5;
+
+// Bit-field mismatch
+struct S6 { int i : 8; unsigned j : 8; } x6;
+
+// Bit-field mismatch
+struct S7 { int i : 8; unsigned j : 8; } x7;
+
+// Incomplete type
+struct S8 *x8;
+
+// Incomplete type
+struct S9 { int i; float f; } *x9;
+
+// Incomplete type
+struct S10 *x10;
+
+// Matches
+struct ListNode {
+ int value;
+ struct ListNode *Next;
+} xList;
+
+// Mismatch due to struct used internally
+struct DeepError {
+ int value;
+ struct DeeperError { int i; int f; } *Deeper;
+} xDeep;
+
+// Matches
+struct {
+ Int i;
+ float f;
+} x11;
diff --git a/clang/test/ASTMerge/Inputs/struct2.c b/clang/test/ASTMerge/Inputs/struct2.c
new file mode 100644
index 0000000..4b43df7
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/struct2.c
@@ -0,0 +1,60 @@
+// Matches
+struct S0 {
+ int field1;
+ float field2;
+};
+
+struct S0 x0;
+
+// Mismatch in field type
+struct S1 {
+ int field1;
+ float field2;
+};
+
+struct S1 x1;
+
+// Mismatch in tag kind.
+union S2 { int i; float f; } x2;
+
+// Missing fields
+struct S3 { int i; float f; } x3;
+
+// Extra fields
+struct S4 { int i; float f; } x4;
+
+// Bit-field matches
+struct S5 { int i : 8; unsigned j : 8; } x5;
+
+// Bit-field mismatch
+struct S6 { int i : 8; unsigned j; } x6;
+
+// Bit-field mismatch
+struct S7 { int i : 8; unsigned j : 16; } x7;
+
+// Incomplete type
+struct S8 { int i; float f; } *x8;
+
+// Incomplete type
+struct S9 *x9;
+
+// Incomplete type
+struct S10 *x10;
+
+// Matches
+struct ListNode {
+ int value;
+ struct ListNode *Next;
+} xList;
+
+// Mismatch due to struct used internally
+struct DeepError {
+ int value;
+ struct DeeperError { int i; float f; } *Deeper;
+} xDeep;
+
+// Matches
+struct {
+ int i;
+ float f;
+} x11;
diff --git a/clang/test/ASTMerge/Inputs/typedef1.c b/clang/test/ASTMerge/Inputs/typedef1.c
new file mode 100644
index 0000000..5657675
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/typedef1.c
@@ -0,0 +1,4 @@
+typedef int Typedef1;
+typedef int Typedef2;
+Typedef1 x1;
+Typedef2 x2;
diff --git a/clang/test/ASTMerge/Inputs/typedef2.c b/clang/test/ASTMerge/Inputs/typedef2.c
new file mode 100644
index 0000000..129d710
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/typedef2.c
@@ -0,0 +1,4 @@
+typedef int Typedef1;
+typedef double Typedef2;
+Typedef1 x1;
+Typedef2 x2;
diff --git a/clang/test/ASTMerge/Inputs/var1.c b/clang/test/ASTMerge/Inputs/var1.c
new file mode 100644
index 0000000..4f5cbe1
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/var1.c
@@ -0,0 +1,7 @@
+int *x0;
+float **x1;
+#include "var1.h"
+int xarray0[17];
+int xarray1[];
+int xarray2[18];
+int xarray3[18];
diff --git a/clang/test/ASTMerge/Inputs/var1.h b/clang/test/ASTMerge/Inputs/var1.h
new file mode 100644
index 0000000..1518e17
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/var1.h
@@ -0,0 +1 @@
+double x2;
diff --git a/clang/test/ASTMerge/Inputs/var2.c b/clang/test/ASTMerge/Inputs/var2.c
new file mode 100644
index 0000000..01986e4
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/var2.c
@@ -0,0 +1,7 @@
+int *x0;
+double *x1;
+int x2;
+int xarray0[17];
+int xarray1[17];
+int xarray2[];
+int xarray3[17];
diff --git a/clang/test/ASTMerge/category.m b/clang/test/ASTMerge/category.m
new file mode 100644
index 0000000..54a1240
--- /dev/null
+++ b/clang/test/ASTMerge/category.m
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/category1.m
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/category2.m
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: category2.m:18:1: error: instance method 'method2' has incompatible result types in different translation units ('float' vs. 'int')
+// CHECK: category1.m:16:1: note: instance method 'method2' also declared here
+// CHECK: category2.m:26:1: error: instance method 'method3' has incompatible result types in different translation units ('float' vs. 'int')
+// CHECK: category1.m:24:1: note: instance method 'method3' also declared here
+// CHECK: category2.m:48:1: error: instance method 'blah' has incompatible result types in different translation units ('int' vs. 'float')
+// CHECK: category1.m:46:1: note: instance method 'blah' also declared here
+// CHECK: 3 errors generated.
diff --git a/clang/test/ASTMerge/class-template.cpp b/clang/test/ASTMerge/class-template.cpp
new file mode 100644
index 0000000..eea31b1
--- /dev/null
+++ b/clang/test/ASTMerge/class-template.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/class-template1.cpp
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/class-template2.cpp
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: class-template1.cpp:7:14: error: non-type template parameter declared with incompatible types in different translation units ('int' vs. 'long')
+// CHECK: class-template2.cpp:7:15: note: declared here with type 'long'
+
+// CHECK: class-template1.cpp:10:14: error: template parameter has different kinds in different translation units
+// CHECK: class-template2.cpp:10:10: note: template parameter declared here
+
+// CHECK: class-template1.cpp:16:23: error: non-type template parameter declared with incompatible types in different translation units ('long' vs. 'int')
+// CHECK: class-template2.cpp:16:23: note: declared here with type 'int'
+
+// CHECK: class-template1.cpp:19:10: error: template parameter has different kinds in different translation units
+// CHECK: class-template2.cpp:19:10: note: template parameter declared here
+
+// CHECK: class-template2.cpp:25:20: error: external variable 'x0r' declared with incompatible types in different translation units ('X0<double> *' vs. 'X0<float> *')
+// CHECK: class-template1.cpp:24:19: note: declared here with type 'X0<float> *'
+
+// CHECK: class-template1.cpp:32:8: warning: type 'X0<wchar_t>' has incompatible definitions in different translation units
+// CHECK: class-template1.cpp:33:7: note: field 'member' has type 'int' here
+// CHECK: class-template2.cpp:34:9: note: field 'member' has type 'float' here
+
+// CHECK: 1 warning and 5 errors generated.
diff --git a/clang/test/ASTMerge/class.cpp b/clang/test/ASTMerge/class.cpp
new file mode 100644
index 0000000..114687f
--- /dev/null
+++ b/clang/test/ASTMerge/class.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/class1.cpp
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/class2.cpp
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: class1.cpp:5:8: warning: type 'B' has incompatible definitions in different translation units
+// CHECK: class1.cpp:6:9: note: field 'y' has type 'float' here
+// CHECK: class2.cpp:6:7: note: field 'y' has type 'int' here
+
+// FIXME: we should also complain about mismatched types on the method
diff --git a/clang/test/ASTMerge/enum.c b/clang/test/ASTMerge/enum.c
new file mode 100644
index 0000000..4380d19
--- /dev/null
+++ b/clang/test/ASTMerge/enum.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/enum1.c
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/enum2.c
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: enum1.c:9:6: warning: type 'enum E2' has incompatible definitions in different translation units
+// CHECK: enum1.c:11:3: note: enumerator 'E2Enumerator2' with value 3 here
+// CHECK: enum2.c:11:3: note: enumerator 'E2Enumerator2' with value 4 here
+// CHECK: enum2.c:13:3: error: external variable 'x2' declared with incompatible types in different translation units ('enum E2' vs. 'enum E2')
+// CHECK: enum1.c:13:3: note: declared here with type 'enum E2'
+// CHECK: enum1.c:16:6: warning: type 'enum E3' has incompatible definitions in different translation units
+// CHECK: enum1.c:18:3: note: enumerator 'E3Enumerator2' with value 3 here
+// CHECK: enum2.c:18:3: note: enumerator 'E3Enumerator' with value 3 here
+// CHECK: enum2.c:20:3: error: external variable 'x3' declared with incompatible types in different translation units ('enum E3' vs. 'enum E3')
+// CHECK: enum1.c:20:3: note: declared here with type 'enum E3'
+// CHECK: enum1.c:23:6: warning: type 'enum E4' has incompatible definitions in different translation units
+// CHECK: enum1.c:26:3: note: enumerator 'E4Enumerator3' with value 2 here
+// CHECK: enum2.c:23:6: note: no corresponding enumerator here
+// CHECK: enum2.c:26:3: error: external variable 'x4' declared with incompatible types in different translation units ('enum E4' vs. 'enum E4')
+// CHECK: enum1.c:27:3: note: declared here with type 'enum E4'
+// CHECK: enum1.c:30:6: warning: type 'enum E5' has incompatible definitions in different translation units
+// CHECK: enum2.c:33:3: note: enumerator 'E5Enumerator4' with value 3 here
+// CHECK: enum1.c:30:6: note: no corresponding enumerator here
+// CHECK: enum2.c:34:3: error: external variable 'x5' declared with incompatible types in different translation units ('enum E5' vs. 'enum E5')
+// CHECK: enum1.c:34:3: note: declared here with type 'enum E5'
+// CHECK: 4 warnings and 4 errors generated
diff --git a/clang/test/ASTMerge/exprs.c b/clang/test/ASTMerge/exprs.c
new file mode 100644
index 0000000..0a4e1e5
--- /dev/null
+++ b/clang/test/ASTMerge/exprs.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/exprs1.c
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/exprs2.c
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only -verify %s
+
diff --git a/clang/test/ASTMerge/function.c b/clang/test/ASTMerge/function.c
new file mode 100644
index 0000000..f97ecee
--- /dev/null
+++ b/clang/test/ASTMerge/function.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/function1.c
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/function2.c
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: function2.c:3:6: error: external function 'f1' declared with incompatible types in different translation units ('void (Int, double)' vs. 'void (int, float)')
+// CHECK: function1.c:2:6: note: declared here with type 'void (int, float)'
+// CHECK: function2.c:5:6: error: external function 'f3' declared with incompatible types in different translation units ('void (int)' vs. 'void (void)')
+// CHECK: function1.c:4:6: note: declared here with type 'void (void)'
+// CHECK: 2 errors generated
diff --git a/clang/test/ASTMerge/interface.m b/clang/test/ASTMerge/interface.m
new file mode 100644
index 0000000..747ef38
--- /dev/null
+++ b/clang/test/ASTMerge/interface.m
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/interface1.m
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/interface2.m
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: interface2.m:16:9: error: instance variable 'ivar2' declared with incompatible types in different translation units ('float' vs. 'int')
+// CHECK: interface1.m:16:7: note: declared here with type 'int'
+// CHECK: interface1.m:21:12: error: class 'I4' has incompatible superclasses
+// CHECK: interface1.m:21:17: note: inherits from superclass 'I2' here
+// CHECK: interface2.m:21:17: note: inherits from superclass 'I1' here
+// CHECK: interface2.m:33:1: error: class method 'foo' has incompatible result types in different translation units ('float' vs. 'int')
+// CHECK: interface1.m:34:1: note: class method 'foo' also declared here
+// CHECK: interface2.m:39:19: error: class method 'bar:' has a parameter with a different types in different translation units ('float' vs. 'int')
+// CHECK: interface1.m:40:17: note: declared here with type 'int'
+// CHECK: interface2.m:45:1: error: class method 'bar:' is variadic in one translation unit and not variadic in another
+// CHECK: interface1.m:46:1: note: class method 'bar:' also declared here
+// CHECK: interface2.m:57:20: error: instance method 'bar:' has a parameter with a different types in different translation units ('double' vs. 'float')
+// CHECK: interface1.m:58:19: note: declared here with type 'float'
+// CHECK: interface1.m:100:17: error: class 'I15' has incompatible superclasses
+// CHECK: interface1.m:100:17: note: inherits from superclass 'I12' here
+// CHECK: interface2.m:99:17: note: inherits from superclass 'I11' here
+// CHECK: 8 errors generated
+
diff --git a/clang/test/ASTMerge/namespace.cpp b/clang/test/ASTMerge/namespace.cpp
new file mode 100644
index 0000000..6c46f0a
--- /dev/null
+++ b/clang/test/ASTMerge/namespace.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/namespace1.cpp
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/namespace2.cpp
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: namespace2.cpp:16:17: error: external variable 'z' declared with incompatible types in different translation units ('double' vs. 'float')
+// CHECK: namespace1.cpp:16:16: note: declared here with type 'float'
diff --git a/clang/test/ASTMerge/property.m b/clang/test/ASTMerge/property.m
new file mode 100644
index 0000000..a8dd7c4
--- /dev/null
+++ b/clang/test/ASTMerge/property.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/property1.m
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/property2.m
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: property2.m:12:26: error: property 'Prop1' declared with incompatible types in different translation units ('int' vs. 'float')
+// CHECK: property1.m:10:28: note: declared here with type 'float'
+// CHECK: property2.m:12:26: error: instance method 'Prop1' has incompatible result types in different translation units ('int' vs. 'float')
+// CHECK: property1.m:10:28: note: instance method 'Prop1' also declared here
+// CHECK: property1.m:28:21: error: property 'Prop2' is synthesized to different ivars in different translation units ('ivar3' vs. 'ivar2')
+// CHECK: property2.m:29:21: note: property is synthesized to ivar 'ivar2' here
+// CHECK: property1.m:29:10: error: property 'Prop3' is implemented with @dynamic in one translation but @synthesize in another translation unit
+// CHECK: property2.m:31:13: note: property 'Prop3' is implemented with @synthesize here
+// CHECK: 4 errors generated.
diff --git a/clang/test/ASTMerge/struct.c b/clang/test/ASTMerge/struct.c
new file mode 100644
index 0000000..7217222
--- /dev/null
+++ b/clang/test/ASTMerge/struct.c
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/struct1.c
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/struct2.c
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: struct1.c:13:8: warning: type 'struct S1' has incompatible definitions in different translation units
+// CHECK: struct1.c:15:7: note: field 'field2' has type 'int' here
+// CHECK: struct2.c:12:9: note: field 'field2' has type 'float' here
+// CHECK: struct2.c:15:11: error: external variable 'x1' declared with incompatible types in different translation units ('struct S1' vs. 'struct S1')
+// CHECK: struct1.c:18:11: note: declared here with type 'struct S1'
+// CHECK: struct1.c:21:8: warning: type 'struct S2' has incompatible definitions in different translation units
+// CHECK: struct2.c:18:7: note: 'S2' is a union here
+// CHECK: struct2.c:18:30: error: external variable 'x2' declared with incompatible types in different translation units ('union S2' vs. 'struct S2')
+// CHECK: struct1.c:21:31: note: declared here with type 'struct S2'
+// CHECK: struct1.c:24:8: warning: type 'struct S3' has incompatible definitions in different translation units
+// CHECK: struct1.c:24:36: note: field 'd' has type 'double' here
+// CHECK: struct2.c:21:8: note: no corresponding field here
+// CHECK: struct2.c:21:31: error: external variable 'x3' declared with incompatible types in different translation units ('struct S3' vs. 'struct S3')
+// CHECK: struct1.c:24:41: note: declared here with type 'struct S3'
+// CHECK: struct1.c:27:8: warning: type 'struct S4' has incompatible definitions in different translation units
+// CHECK: struct2.c:24:26: note: field 'f' has type 'float' here
+// CHECK: struct1.c:27:8: note: no corresponding field here
+// CHECK: struct2.c:24:31: error: external variable 'x4' declared with incompatible types in different translation units ('struct S4' vs. 'struct S4')
+// CHECK: struct1.c:27:22: note: declared here with type 'struct S4'
+// CHECK: struct1.c:33:8: warning: type 'struct S6' has incompatible definitions in different translation units
+// CHECK: struct1.c:33:33: note: bit-field 'j' with type 'unsigned int' and length 8 here
+// CHECK: struct2.c:30:33: note: field 'j' is not a bit-field
+// CHECK: struct2.c:30:38: error: external variable 'x6' declared with incompatible types in different translation units ('struct S6' vs. 'struct S6')
+// CHECK: struct1.c:33:42: note: declared here with type 'struct S6'
+// CHECK: struct1.c:36:8: warning: type 'struct S7' has incompatible definitions in different translation units
+// CHECK: struct1.c:36:33: note: bit-field 'j' with type 'unsigned int' and length 8 here
+// CHECK: struct2.c:33:33: note: bit-field 'j' with type 'unsigned int' and length 16 here
+// CHECK: struct2.c:33:43: error: external variable 'x7' declared with incompatible types in different translation units ('struct S7' vs. 'struct S7')
+// CHECK: struct1.c:36:42: note: declared here with type 'struct S7'
+// CHECK: struct1.c:56:10: warning: type 'struct DeeperError' has incompatible definitions in different translation units
+// CHECK: struct1.c:56:35: note: field 'f' has type 'int' here
+// CHECK: struct2.c:53:37: note: field 'f' has type 'float' here
+// CHECK: struct1.c:54:8: warning: type 'struct DeepError' has incompatible definitions in different translation units
+// CHECK: struct1.c:56:41: note: field 'Deeper' has type 'struct DeeperError *' here
+// CHECK: struct2.c:53:43: note: field 'Deeper' has type 'struct DeeperError *' here
+// CHECK: struct2.c:54:3: error: external variable 'xDeep' declared with incompatible types in different translation units ('struct DeepError' vs. 'struct DeepError')
+// CHECK: struct1.c:57:3: note: declared here with type 'struct DeepError'
+// CHECK: 8 warnings and 7 errors generated
diff --git a/clang/test/ASTMerge/typedef.c b/clang/test/ASTMerge/typedef.c
new file mode 100644
index 0000000..6f91129
--- /dev/null
+++ b/clang/test/ASTMerge/typedef.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/typedef1.c
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/typedef2.c
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: typedef2.c:4:10: error: external variable 'x2' declared with incompatible types in different translation units ('Typedef2' (aka 'double') vs. 'Typedef2' (aka 'int'))
+// CHECK: typedef1.c:4:10: note: declared here with type 'Typedef2' (aka 'int')
+// CHECK: 1 error
diff --git a/clang/test/ASTMerge/var.c b/clang/test/ASTMerge/var.c
new file mode 100644
index 0000000..e1dde6a
--- /dev/null
+++ b/clang/test/ASTMerge/var.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/var1.c
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/var2.c
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only -fdiagnostics-show-note-include-stack %s 2>&1 | FileCheck %s
+
+// CHECK: var2.c:2:9: error: external variable 'x1' declared with incompatible types in different translation units ('double *' vs. 'float **')
+// CHECK: var1.c:2:9: note: declared here with type 'float **'
+// CHECK: var2.c:3:5: error: external variable 'x2' declared with incompatible types in different translation units ('int' vs. 'double')
+// CHECK: In file included from{{.*}}var1.c:3:
+// CHECK: var1.h:1:8: note: declared here with type 'double'
+// CHECK: error: external variable 'xarray3' declared with incompatible types in different translation units ('int [17]' vs. 'int [18]')
+// CHECK: var1.c:7:5: note: declared here with type 'int [18]'
+// CHECK: 3 errors