mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-24 01:58:21 +00:00
a45f713c67
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
48 lines
992 B
C++
48 lines
992 B
C++
// Test this without pch.
|
|
// RUN: %clang_cc1 %s -include %s -verify -fsyntax-only -Wuninitialized
|
|
|
|
// Test with pch.
|
|
// RUN: %clang_cc1 %s -emit-pch -o %t
|
|
// RUN: %clang_cc1 %s -include-pch %t -verify -fsyntax-only -Wuninitialized
|
|
|
|
// RUN: %clang_cc1 %s -emit-pch -fpch-instantiate-templates -o %t
|
|
// RUN: %clang_cc1 %s -include-pch %t -verify -fsyntax-only -Wuninitialized
|
|
|
|
#ifndef HEADER
|
|
#define HEADER
|
|
|
|
#pragma clang diagnostic push
|
|
#pragma clang diagnostic ignored "-Wuninitialized"
|
|
template <typename T>
|
|
struct TS1 {
|
|
void m() {
|
|
T a;
|
|
T b = a;
|
|
}
|
|
};
|
|
#pragma clang diagnostic pop
|
|
|
|
#else
|
|
|
|
|
|
template <typename T>
|
|
struct TS2 {
|
|
void m() {
|
|
T a;
|
|
T b = a; // expected-warning {{variable 'a' is uninitialized}} \
|
|
expected-note@44 {{in instantiation of member function}} \
|
|
expected-note@31 {{initialize the variable 'a' to silence}}
|
|
}
|
|
};
|
|
|
|
void f() {
|
|
TS1<int> ts1;
|
|
ts1.m();
|
|
|
|
|
|
TS2<int> ts2;
|
|
ts2.m();
|
|
}
|
|
|
|
#endif
|