2010-08-24 04:50:16 +04:00
|
|
|
// Test C++ chained PCH functionality
|
|
|
|
|
|
|
|
// Without PCH
|
2010-10-20 01:54:32 +04:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -include %s -include %s %s
|
2010-08-24 04:50:16 +04:00
|
|
|
|
|
|
|
// With PCH
|
2011-03-09 20:21:42 +03:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s -chain-include %s -chain-include %s
|
2010-08-24 04:50:16 +04:00
|
|
|
|
2012-10-19 16:44:48 +04:00
|
|
|
// expected-no-diagnostics
|
|
|
|
|
2010-10-20 01:54:32 +04:00
|
|
|
#ifndef HEADER1
|
|
|
|
#define HEADER1
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Primary header for C++ chained PCH test
|
|
|
|
|
|
|
|
void f();
|
|
|
|
|
|
|
|
// Name not appearing in dependent
|
|
|
|
void pf();
|
|
|
|
|
|
|
|
namespace ns {
|
|
|
|
void g();
|
|
|
|
|
|
|
|
void pg();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct S { typedef int G; };
|
|
|
|
|
|
|
|
// Partially specialize
|
|
|
|
template <typename T>
|
|
|
|
struct S<T *> { typedef int H; };
|
|
|
|
|
2010-10-20 04:11:15 +04:00
|
|
|
template <typename T> struct TS2;
|
|
|
|
typedef TS2<int> TS2int;
|
|
|
|
|
2011-03-09 08:09:32 +03:00
|
|
|
template <typename T> struct TestBaseSpecifiers { };
|
|
|
|
template<typename T> struct TestBaseSpecifiers2 : TestBaseSpecifiers<T> { };
|
|
|
|
|
2011-04-29 12:19:30 +04:00
|
|
|
template <typename T>
|
|
|
|
struct TS3 {
|
|
|
|
static const int value = 0;
|
2011-12-21 04:25:33 +04:00
|
|
|
static const int value2;
|
2011-04-29 12:19:30 +04:00
|
|
|
};
|
|
|
|
template <typename T>
|
|
|
|
const int TS3<T>::value;
|
2011-12-21 04:25:33 +04:00
|
|
|
template <typename T>
|
|
|
|
const int TS3<T>::value2 = 1;
|
2011-04-29 12:19:30 +04:00
|
|
|
// Instantiate struct, but not value.
|
|
|
|
struct instantiate : TS3<int> {};
|
|
|
|
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146841 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-18 03:38:30 +04:00
|
|
|
// Typedef
|
|
|
|
typedef int Integer;
|
2011-04-29 12:19:30 +04:00
|
|
|
|
2010-10-20 01:54:32 +04:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#elif not defined(HEADER2)
|
|
|
|
#define HEADER2
|
2011-04-29 12:19:30 +04:00
|
|
|
#if !defined(HEADER1)
|
|
|
|
#error Header inclusion order messed up
|
|
|
|
#endif
|
|
|
|
|
2010-10-20 01:54:32 +04:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Dependent header for C++ chained PCH test
|
|
|
|
|
|
|
|
// Overload function from primary
|
|
|
|
void f(int);
|
|
|
|
|
|
|
|
// Add function with different name
|
|
|
|
void f2();
|
|
|
|
|
|
|
|
// Reopen namespace
|
|
|
|
namespace ns {
|
|
|
|
// Overload function from primary
|
|
|
|
void g(int);
|
|
|
|
|
|
|
|
// Add different name
|
|
|
|
void g2();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Specialize template from primary
|
|
|
|
template <>
|
|
|
|
struct S<int> { typedef int I; };
|
|
|
|
|
|
|
|
// Partially specialize
|
|
|
|
template <typename T>
|
|
|
|
struct S<T &> { typedef int J; };
|
|
|
|
|
|
|
|
// Specialize previous partial specialization
|
|
|
|
template <>
|
|
|
|
struct S<int *> { typedef int K; };
|
|
|
|
|
|
|
|
// Specialize the partial specialization from this file
|
|
|
|
template <>
|
|
|
|
struct S<int &> { typedef int L; };
|
|
|
|
|
2010-10-20 04:11:15 +04:00
|
|
|
template <typename T> struct TS2 { };
|
|
|
|
|
2011-03-09 08:09:32 +03:00
|
|
|
struct TestBaseSpecifiers3 { };
|
|
|
|
struct TestBaseSpecifiers4 : TestBaseSpecifiers3 { };
|
|
|
|
|
2011-03-06 21:41:18 +03:00
|
|
|
struct A { };
|
|
|
|
struct B : A { };
|
|
|
|
|
2011-12-21 04:25:33 +04:00
|
|
|
// Instantiate TS3's members.
|
2011-04-29 12:19:30 +04:00
|
|
|
static const int ts3m1 = TS3<int>::value;
|
2011-12-21 04:25:33 +04:00
|
|
|
extern int arr[TS3<int>::value2];
|
2011-04-29 12:19:30 +04: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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146841 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-18 03:38:30 +04:00
|
|
|
// Redefinition of typedef
|
|
|
|
typedef int Integer;
|
|
|
|
|
2010-10-20 01:54:32 +04:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#else
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2010-08-24 04:50:16 +04:00
|
|
|
void test() {
|
|
|
|
f();
|
|
|
|
f(1);
|
|
|
|
pf();
|
|
|
|
f2();
|
|
|
|
|
|
|
|
ns::g();
|
|
|
|
ns::g(1);
|
|
|
|
ns::pg();
|
|
|
|
ns::g2();
|
|
|
|
|
2010-08-25 02:50:24 +04:00
|
|
|
typedef S<double>::G T1;
|
|
|
|
typedef S<double *>::H T2;
|
|
|
|
typedef S<int>::I T3;
|
|
|
|
typedef S<double &>::J T4;
|
|
|
|
typedef S<int *>::K T5;
|
|
|
|
typedef S<int &>::L T6;
|
2010-10-20 04:11:15 +04:00
|
|
|
|
|
|
|
TS2int ts2;
|
2011-03-06 21:41:18 +03:00
|
|
|
|
|
|
|
B b;
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146841 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-18 03:38:30 +04:00
|
|
|
Integer i = 17;
|
2010-08-24 04:50:16 +04:00
|
|
|
}
|
2010-10-20 01:54:32 +04:00
|
|
|
|
2011-04-29 12:19:30 +04:00
|
|
|
// Should have remembered that there is a definition.
|
|
|
|
static const int ts3m2 = TS3<int>::value;
|
2011-12-21 04:25:33 +04:00
|
|
|
int arr[TS3<int>::value2];
|
2011-04-29 12:19:30 +04:00
|
|
|
|
2010-10-20 01:54:32 +04:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#endif
|