Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / PCH / delayed-pch-instantiate.cpp
blobd340b3b8b25d150954598ddbdabdc8a6ecded63b
1 // Test this without pch.
2 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -DBODY %s -o - | FileCheck %s
4 // Test with pch.
5 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-pch -o %t %s
6 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -include-pch %t -DBODY %s -o - | FileCheck %s
8 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-pch -fpch-instantiate-templates -o %t %s
9 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -include-pch %t -DBODY %s -o - | FileCheck %s
11 // expected-no-diagnostics
13 #ifndef HEADER_H
14 #define HEADER_H
15 struct A {
16 void foo() { bar<0>(); } // This will trigger implicit instantiation of bar<0>() in the PCH.
17 template <int N>
18 void bar();
20 #endif
22 #ifdef BODY
23 // But the definition is only in the source, so the instantiation must be delayed until the TU.
24 template <int N>
25 void A::bar() {}
27 void test(A *a) { a->foo(); }
28 #endif
30 // CHECK: define linkonce_odr void @_ZN1A3barILi0EEEvv