Skip to content

Commit a45f713

Browse files
committed
add option to instantiate templates already in the PCH
Add -fpch-instantiate-templates which makes template instantiations be performed already in the PCH instead of it being done in every single file that uses the PCH (but every single file will still do it as well in order to handle its own instantiations). I can see 20-30% build time saved with the few tests I've tried. The change may reorder compiler output and also generated code, but should be generally safe and produce functionally identical code. There are some rare cases that do not compile with it, such as test/PCH/pch-instantiate-templates-forward-decl.cpp. If template instantiation bailed out instead of reporting the error, these instantiations could even be postponed, which would make them work. Enable this by default for clang-cl. MSVC creates PCHs by compiling them using an empty .cpp file, which means templates are instantiated while building the PCH and so the .h needs to be self-contained, making test/PCH/pch-instantiate-templates-forward-decl.cpp to fail with MSVC anyway. So the option being enabled for clang-cl matches this. Differential Revision: https://reviews.llvm.org/D69585
1 parent 730ecb6 commit a45f713

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+333
-33
lines changed

clang/include/clang/Basic/LangOptions.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ BENIGN_ENUM_LANGOPT(CompilingModule, CompilingModuleKind, 2, CMK_None,
165165
BENIGN_LANGOPT(CompilingPCH, 1, 0, "building a pch")
166166
BENIGN_LANGOPT(BuildingPCHWithObjectFile, 1, 0, "building a pch which has a corresponding object file")
167167
BENIGN_LANGOPT(CacheGeneratedPCH, 1, 0, "cache generated PCH files in memory")
168+
BENIGN_LANGOPT(PCHInstantiateTemplates, 1, 0, "instantiate templates while building a PCH")
168169
COMPATIBLE_LANGOPT(ModulesDeclUse , 1, 0, "require declaration of module uses")
169170
BENIGN_LANGOPT(ModulesSearchAll , 1, 1, "searching even non-imported modules to find unresolved references")
170171
COMPATIBLE_LANGOPT(ModulesStrictDeclUse, 1, 0, "requiring declaration of module uses and all headers to be in modules")

clang/include/clang/Driver/Options.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,6 +1420,13 @@ def fpch_validate_input_files_content:
14201420
def fno_pch_validate_input_files_content:
14211421
Flag <["-"], "fno_pch-validate-input-files-content">,
14221422
Group<f_Group>, Flags<[DriverOption]>;
1423+
def fpch_instantiate_templates:
1424+
Flag <["-"], "fpch-instantiate-templates">,
1425+
Group<f_Group>, Flags<[CC1Option]>,
1426+
HelpText<"Instantiate templates already while building a PCH">;
1427+
def fno_pch_instantiate_templates:
1428+
Flag <["-"], "fno-pch-instantiate-templates">,
1429+
Group<f_Group>, Flags<[CC1Option]>;
14231430

14241431
def fmodules : Flag <["-"], "fmodules">, Group<f_Group>,
14251432
Flags<[DriverOption, CC1Option]>,

clang/include/clang/Sema/Sema.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8804,9 +8804,17 @@ class Sema final {
88048804
S.VTableUses.swap(SavedVTableUses);
88058805

88068806
// Restore the set of pending implicit instantiations.
8807-
assert(S.PendingInstantiations.empty() &&
8808-
"PendingInstantiations should be empty before it is discarded.");
8809-
S.PendingInstantiations.swap(SavedPendingInstantiations);
8807+
if (S.TUKind != TU_Prefix || !S.LangOpts.PCHInstantiateTemplates) {
8808+
assert(S.PendingInstantiations.empty() &&
8809+
"PendingInstantiations should be empty before it is discarded.");
8810+
S.PendingInstantiations.swap(SavedPendingInstantiations);
8811+
} else {
8812+
// Template instantiations in the PCH may be delayed until the TU.
8813+
S.PendingInstantiations.swap(SavedPendingInstantiations);
8814+
S.PendingInstantiations.insert(S.PendingInstantiations.end(),
8815+
SavedPendingInstantiations.begin(),
8816+
SavedPendingInstantiations.end());
8817+
}
88108818
}
88118819

88128820
private:

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,6 +1241,7 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
12411241
if (YcArg && JA.getKind() >= Action::PrecompileJobClass &&
12421242
JA.getKind() <= Action::AssembleJobClass) {
12431243
CmdArgs.push_back(Args.MakeArgString("-building-pch-with-obj"));
1244+
CmdArgs.push_back(Args.MakeArgString("-fpch-instantiate-templates"));
12441245
}
12451246
if (YcArg || YuArg) {
12461247
StringRef ThroughHeader = YcArg ? YcArg->getValue() : YuArg->getValue();
@@ -5633,6 +5634,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
56335634
if (Args.hasFlag(options::OPT_fpch_validate_input_files_content,
56345635
options::OPT_fno_pch_validate_input_files_content, false))
56355636
CmdArgs.push_back("-fvalidate-ast-input-files-content");
5637+
if (Args.hasFlag(options::OPT_fpch_instantiate_templates,
5638+
options::OPT_fno_pch_instantiate_templates, false))
5639+
CmdArgs.push_back("-fpch-instantiate-templates");
56365640

56375641
Args.AddLastArg(CmdArgs, options::OPT_fexperimental_new_pass_manager,
56385642
options::OPT_fno_experimental_new_pass_manager);

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3370,6 +3370,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
33703370

33713371
Opts.CompleteMemberPointers = Args.hasArg(OPT_fcomplete_member_pointers);
33723372
Opts.BuildingPCHWithObjectFile = Args.hasArg(OPT_building_pch_with_obj);
3373+
Opts.PCHInstantiateTemplates = Args.hasArg(OPT_fpch_instantiate_templates);
33733374

33743375
Opts.MatrixTypes = Args.hasArg(OPT_fenable_matrix);
33753376

clang/lib/Sema/Sema.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,11 @@ void Sema::ActOnEndOfTranslationUnit() {
10101010
LateParsedInstantiations.begin(),
10111011
LateParsedInstantiations.end());
10121012
LateParsedInstantiations.clear();
1013+
1014+
if (LangOpts.PCHInstantiateTemplates) {
1015+
llvm::TimeTraceScope TimeScope("PerformPendingInstantiations");
1016+
PerformPendingInstantiations();
1017+
}
10131018
}
10141019

10151020
DiagnoseUnterminatedPragmaPack();

clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5926,6 +5926,7 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D,
59265926
/// Performs template instantiation for all implicit template
59275927
/// instantiations we have seen until this point.
59285928
void Sema::PerformPendingInstantiations(bool LocalOnly) {
5929+
std::deque<PendingImplicitInstantiation> delayedPCHInstantiations;
59295930
while (!PendingLocalImplicitInstantiations.empty() ||
59305931
(!LocalOnly && !PendingInstantiations.empty())) {
59315932
PendingImplicitInstantiation Inst;
@@ -5956,6 +5957,10 @@ void Sema::PerformPendingInstantiations(bool LocalOnly) {
59565957
if (Function->isDefined())
59575958
Function->setInstantiationIsPending(false);
59585959
}
5960+
// Definition of a PCH-ed template declaration may be available only in the TU.
5961+
if (!LocalOnly && LangOpts.PCHInstantiateTemplates &&
5962+
TUKind == TU_Prefix && Function->instantiationIsPending())
5963+
delayedPCHInstantiations.push_back(Inst);
59595964
continue;
59605965
}
59615966

@@ -6001,6 +6006,9 @@ void Sema::PerformPendingInstantiations(bool LocalOnly) {
60016006
InstantiateVariableDefinition(/*FIXME:*/ Inst.second, Var, true,
60026007
DefinitionRequired, true);
60036008
}
6009+
6010+
if (!LocalOnly && LangOpts.PCHInstantiateTemplates)
6011+
PendingInstantiations.swap(delayedPCHInstantiations);
60046012
}
60056013

60066014
void Sema::PerformDependentDiagnostics(const DeclContext *Pattern,

clang/test/PCH/crash-12631281.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// RUN: %clang_cc1 -std=c++11 %s -emit-pch -o %t.pch
22
// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -include-pch %t.pch -verify
3+
4+
// RUN: %clang_cc1 -std=c++11 %s -emit-pch -fpch-instantiate-templates -o %t.pch
5+
// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -include-pch %t.pch -verify
6+
37
// expected-no-diagnostics
48

59
// rdar://12631281

clang/test/PCH/cxx-alias-decl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
// RUN: %clang_cc1 -x c++ -std=c++11 -emit-pch -o %t %S/cxx-alias-decl.h
66
// RUN: %clang_cc1 -x c++ -std=c++11 -include-pch %t -fsyntax-only -emit-llvm -o - %s
77

8+
// RUN: %clang_cc1 -x c++ -std=c++11 -emit-pch -fpch-instantiate-templates -o %t %S/cxx-alias-decl.h
9+
// RUN: %clang_cc1 -x c++ -std=c++11 -include-pch %t -fsyntax-only -emit-llvm -o - %s
10+
811
template struct T<S>;
912
C<A>::A<char> a;
1013

clang/test/PCH/cxx-dependent-sized-ext-vector.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// RUN: %clang_cc1 -std=c++11 -emit-pch %s -o %t
22
// RUN: %clang_cc1 -std=c++11 -include-pch %t -verify %s
33

4+
// RUN: %clang_cc1 -std=c++11 -emit-pch -fpch-instantiate-templates %s -o %t
5+
// RUN: %clang_cc1 -std=c++11 -include-pch %t -verify %s
6+
47
#ifndef HEADER_INCLUDED
58

69
#define HEADER_INCLUDED

clang/test/PCH/cxx-explicit-specifier.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// RUN: %clang_cc1 -std=c++2a -emit-pch %s -o %t-cxx2a
22
// RUN: %clang_cc1 -std=c++2a -DUSE_PCH -include-pch %t-cxx2a %s -ast-print -verify | FileCheck %s
33

4+
// RUN: %clang_cc1 -std=c++2a -emit-pch -fpch-instantiate-templates %s -o %t-cxx2a
5+
// RUN: %clang_cc1 -std=c++2a -DUSE_PCH -include-pch %t-cxx2a %s -ast-print -verify | FileCheck %s
6+
47
#ifndef USE_PCH
58
namespace inheriting_constructor {
69
struct S {};

clang/test/PCH/cxx-exprs.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
// RUN: %clang_cc1 -std=c++11 -emit-pch -o %t %s
66
// RUN: %clang_cc1 -include-pch %t -verify -std=c++11 %s
77

8+
// RUN: %clang_cc1 -std=c++11 -emit-pch -fpch-instantiate-templates -o %t %s
9+
// RUN: %clang_cc1 -include-pch %t -verify -std=c++11 %s
10+
811
// expected-no-diagnostics
912

1013
#ifndef HEADER

clang/test/PCH/cxx-friends.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-friends.h
66
// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s -error-on-deserialized-decl doNotDeserialize
77

8+
// Test with pch and template instantiation in the pch.
9+
// RUN: %clang_cc1 -x c++-header -emit-pch -fpch-instantiate-templates -o %t %S/cxx-friends.h
10+
// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s -error-on-deserialized-decl doNotDeserialize
11+
812
// Test with modules.
913
// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-friends.h -fmodules
1014
// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s -error-on-deserialized-decl doNotDeserialize -fmodules

clang/test/PCH/cxx-member-init.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
// RUN: %clang_cc1 -x c++ -std=c++11 -DHEADER -emit-pch -o %t %s
66
// RUN: %clang_cc1 -x c++ -std=c++11 -DHEADER -include-pch %t -fsyntax-only -emit-llvm -o - %s
77

8+
// RUN: %clang_cc1 -x c++ -std=c++11 -DHEADER -emit-pch -fpch-instantiate-templates -o %t %s
9+
// RUN: %clang_cc1 -x c++ -std=c++11 -DHEADER -include-pch %t -fsyntax-only -emit-llvm -o - %s
10+
811
#ifdef HEADER
912
int n;
1013
struct S {

clang/test/PCH/cxx-ms-function-specialization-class-scope.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// REQUIRES: x86-registered-target
22
// RUN: %clang_cc1 -fms-extensions -triple i386-unknown-unknown -x c++-header -emit-pch -o %t %S/cxx-ms-function-specialization-class-scope.h
33
// RUN: %clang_cc1 -fms-extensions -triple i386-unknown-unknown -include-pch %t -fsyntax-only -verify %s
4+
5+
// RUN: %clang_cc1 -fms-extensions -triple i386-unknown-unknown -x c++-header -emit-pch -fpch-instantiate-templates -o %t %S/cxx-ms-function-specialization-class-scope.h
6+
// RUN: %clang_cc1 -fms-extensions -triple i386-unknown-unknown -include-pch %t -fsyntax-only -verify %s
47
// expected-no-diagnostics
58

69

clang/test/PCH/cxx-static_assert.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
// RUN: %clang_cc1 -std=c++11 -emit-pch -o %t %s
66
// RUN: %clang_cc1 -include-pch %t -verify -std=c++11 %s
77

8+
// RUN: %clang_cc1 -std=c++11 -emit-pch -fpch-instantiate-templates -o %t %s
9+
// RUN: %clang_cc1 -include-pch %t -verify -std=c++11 %s
10+
811
#ifndef HEADER
912
#define HEADER
1013

@@ -14,7 +17,7 @@ template<int N> struct T {
1417

1518
#else
1619

17-
// expected-error@12 {{static_assert failed due to requirement '1 == 2' "N is not 2!"}}
20+
// expected-error@15 {{static_assert failed due to requirement '1 == 2' "N is not 2!"}}
1821
T<1> t1; // expected-note {{in instantiation of template class 'T<1>' requested here}}
1922
T<2> t2;
2023

clang/test/PCH/cxx-templates.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
// RUN: %clang_cc1 -std=c++17 -triple %itanium_abi_triple -fcxx-exceptions -fdelayed-template-parsing -fexceptions -include-pch %t -verify %s
1818
// RUN: %clang_cc1 -std=c++17 -triple %itanium_abi_triple -fcxx-exceptions -fdelayed-template-parsing -fexceptions -include-pch %t %s -emit-llvm -o - -DNO_ERRORS | FileCheck %s
1919

20+
// Test with pch and template instantiation in the pch.
21+
// RUN: %clang_cc1 -std=c++17 -triple %itanium_abi_triple -fcxx-exceptions -fexceptions -fpch-instantiate-templates -x c++-header -emit-pch -o %t %S/cxx-templates.h
22+
// RUN: %clang_cc1 -std=c++17 -triple %itanium_abi_triple -fcxx-exceptions -fexceptions -include-pch %t -verify %s
23+
// RUN: %clang_cc1 -std=c++17 -triple %itanium_abi_triple -fcxx-exceptions -fexceptions -include-pch %t %s -emit-llvm -o - -DNO_ERRORS | FileCheck %s
24+
2025
// CHECK: define weak_odr {{.*}}void @_ZN2S4IiE1mEv
2126
// CHECK: define linkonce_odr {{.*}}void @_ZN2S3IiE1mEv
2227

clang/test/PCH/cxx-variadic-templates-with-default-params.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
// RUN: %clang_cc1 -std=c++11 -x c++-header -emit-pch -o %t %s
66
// RUN: %clang_cc1 -std=c++11 -include-pch %t -fsyntax-only -verify %s
77

8+
// RUN: %clang_cc1 -std=c++11 -x c++-header -emit-pch -fpch-instantiate-templates -o %t %s
9+
// RUN: %clang_cc1 -std=c++11 -include-pch %t -fsyntax-only -verify %s
10+
811
// expected-no-diagnostics
912

1013
// PR25271: Ensure that default template arguments prior to a parameter pack

clang/test/PCH/cxx-variadic-templates.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
// RUN: %clang_cc1 -std=c++11 -include-pch %t -verify %s -ast-dump -o -
88
// RUN: %clang_cc1 -std=c++11 -include-pch %t %s -emit-llvm -o - | FileCheck %s
99

10+
// RUN: %clang_cc1 -std=c++11 -x c++-header -emit-pch -fpch-instantiate-templates -o %t %S/cxx-variadic-templates.h
11+
// RUN: %clang_cc1 -std=c++11 -include-pch %t -verify %s -ast-dump -o -
12+
// RUN: %clang_cc1 -std=c++11 -include-pch %t %s -emit-llvm -o - | FileCheck %s
13+
1014
// expected-no-diagnostics
1115

1216
// CHECK: allocate_shared

clang/test/PCH/cxx0x-default-delete.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
// RUN: %clang_cc1 -x c++-header -std=c++11 -emit-pch -o %t %s
55
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -include-pch %t %s
66

7+
// RUN: %clang_cc1 -x c++-header -std=c++11 -emit-pch -fpch-instantiate-templates -o %t %s
8+
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -include-pch %t %s
9+
710
#ifndef PASS1
811
#define PASS1
912

@@ -30,11 +33,11 @@ struct A {
3033
foo::foo() { } // expected-error{{definition of explicitly defaulted default constructor}}
3134
foo f;
3235
void fn() {
33-
f.bar(); // expected-error{{deleted function}} expected-note@12{{deleted here}}
36+
f.bar(); // expected-error{{deleted function}} expected-note@15{{deleted here}}
3437
}
3538

36-
baz bz; // expected-error{{deleted function}} expected-note@16{{deleted here}}
37-
quux qx; // expected-error{{private destructor}} expected-note@20{{private here}}
39+
baz bz; // expected-error{{deleted function}} expected-note@19{{deleted here}}
40+
quux qx; // expected-error{{private destructor}} expected-note@23{{private here}}
3841

3942
struct B { A a; };
4043
struct C { mutable A a; };

clang/test/PCH/cxx11-constexpr.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// RUN: %clang_cc1 -pedantic-errors -std=c++11 -emit-pch %s -o %t
22
// RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t -verify %s
33

4+
// RUN: %clang_cc1 -pedantic-errors -std=c++11 -emit-pch -fpch-instantiate-templates %s -o %t
5+
// RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t -verify %s
6+
47
#ifndef HEADER_INCLUDED
58

69
#define HEADER_INCLUDED
@@ -31,9 +34,9 @@ constexpr T plus_seven(T other) {
3134

3235
static_assert(D(4).k == 9, "");
3336
constexpr int f(C c) { return 0; } // expected-error {{not a literal type}}
34-
// expected-note@13 {{not an aggregate and has no constexpr constructors}}
37+
// expected-note@16 {{not an aggregate and has no constexpr constructors}}
3538
constexpr B b; // expected-error {{constant expression}} expected-note {{non-constexpr}}
36-
// expected-note@9 {{here}}
39+
// expected-note@12 {{here}}
3740

3841
static_assert(plus_seven(3) == 10, "");
3942

clang/test/PCH/cxx11-enum-template.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// RUN: %clang_cc1 -pedantic-errors -std=c++11 -emit-pch %s -o %t
22
// RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t -verify %s
33

4+
// RUN: %clang_cc1 -pedantic-errors -std=c++11 -emit-pch -fpch-instantiate-templates %s -o %t
5+
// RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t -verify %s
6+
47
#ifndef HEADER_INCLUDED
58

69
#define HEADER_INCLUDED
@@ -20,7 +23,7 @@ template struct S<char>;
2023

2124
int k1 = (int)S<int>::E::e;
2225
int k2 = (int)decltype(b)::e;
23-
int k3 = (int)decltype(c)::e; // expected-error@10 {{conversion from 'double' to 'int'}} expected-note {{here}}
26+
int k3 = (int)decltype(c)::e; // expected-error@13 {{conversion from 'double' to 'int'}} expected-note {{here}}
2427
int k4 = (int)S<char>::E::e;
2528

2629
#endif

clang/test/PCH/cxx11-exception-spec.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
// RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t.1 -emit-pch %s -o %t.2
33
// RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t.2 -verify %s
44
// RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t.2 -emit-llvm-only %s
5+
6+
// RUN: %clang_cc1 -pedantic-errors -std=c++11 -emit-pch -fpch-instantiate-templates %s -o %t.1
7+
// RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t.1 -emit-pch -fpch-instantiate-templates %s -o %t.2
8+
// RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t.2 -verify %s
9+
// RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t.2 -emit-llvm-only %s
10+
511
// expected-no-diagnostics
612

713
#ifndef PHASE1_DONE

clang/test/PCH/cxx11-inheriting-ctors.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,17 @@
44
// RxN: %clang_cc1 -std=c++11 -emit-pch -o %t.12 -include %s %s
55
// RxN: %clang_cc1 -std=c++11 -include-pch %t.12 -verify %s
66
//
7+
// RxN: %clang_cc1 -std=c++11 -emit-pch -fpch-instantiate-templates -o %t.12 -include %s %s
8+
// RxN: %clang_cc1 -std=c++11 -include-pch %t.12 -verify %s
9+
//
710
// Emit with definitions in update records:
811
// RxN: %clang_cc1 -std=c++11 -emit-pch -o %t.1 %s
912
// RxN: %clang_cc1 -std=c++11 -include-pch %t.1 -emit-pch -o %t.2 -verify %s
1013
// RxN: %clang_cc1 -std=c++11 -include-pch %t.1 -include-pch %t.2 -verify %s
14+
//
15+
// RxN: %clang_cc1 -std=c++11 -emit-pch -fpch-instantiate-templates -o %t.1 %s
16+
// RxN: %clang_cc1 -std=c++11 -include-pch %t.1 -emit-pch -fpch-instantiate-templates -o %t.2 -verify %s
17+
// RxN: %clang_cc1 -std=c++11 -include-pch %t.1 -include-pch %t.2 -verify %s
1118

1219

1320
// expected-no-diagnostics

clang/test/PCH/cxx11-user-defined-literals.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// RUN: %clang_cc1 -pedantic-errors -std=c++11 -emit-pch %s -o %t
22
// RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t -verify %s
33

4+
// RUN: %clang_cc1 -pedantic-errors -std=c++11 -emit-pch -fpch-instantiate-templates %s -o %t
5+
// RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t -verify %s
6+
47
#ifndef HEADER_INCLUDED
58

69
#define HEADER_INCLUDED
@@ -17,6 +20,6 @@ int k = f(0);
1720
int *l = f(&k);
1821
struct S {};
1922
int m = f(S()); // expected-error {{no matching}}
20-
// expected-note@11 {{substitution failure}}
23+
// expected-note@14 {{substitution failure}}
2124

2225
#endif

clang/test/PCH/cxx1y-decltype-auto.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// RUN: %clang_cc1 -pedantic -std=c++1y -emit-pch %s -o %t
22
// RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t -verify %s
33

4+
// RUN: %clang_cc1 -pedantic -std=c++1y -emit-pch -fpch-instantiate-templates %s -o %t
5+
// RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t -verify %s
6+
47
#ifndef HEADER_INCLUDED
58

69
#define HEADER_INCLUDED
@@ -18,7 +21,7 @@ struct Z {
1821
int x : 5; // expected-note {{bit-field}}
1922
};
2023

21-
// expected-error@12 {{non-const reference cannot bind to bit-field 'x'}}
24+
// expected-error@15 {{non-const reference cannot bind to bit-field 'x'}}
2225
template void f(Z); // expected-note {{in instantiation of}}
2326

2427
#endif

clang/test/PCH/cxx1y-deduced-return-type.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
// RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t.a -emit-pch %s -o %t.b
77
// RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t.b -verify %s
88

9+
// RUN: %clang_cc1 -pedantic -std=c++1y -emit-pch -fpch-instantiate-templates %s -o %t.a
10+
// RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t.a -emit-pch -fpch-instantiate-templates %s -o %t.b
11+
// RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t.b -verify %s
12+
913
// expected-no-diagnostics
1014

1115
#if !defined(HEADER1)

clang/test/PCH/cxx1y-default-initializer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
// RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t.1 -emit-pch -o %t.2 %s
44
// RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t.2 -verify %s
55

6+
// RUN: %clang_cc1 -pedantic -std=c++1y -emit-pch -fpch-instantiate-templates -o %t.1 %s
7+
// RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t.1 -emit-pch -fpch-instantiate-templates -o %t.2 %s
8+
// RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t.2 -verify %s
9+
610
#ifndef HEADER_1
711
#define HEADER_1
812

0 commit comments

Comments
 (0)