[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / PCH / headersearch.cpp
blobf089bfd9ed1deed9941a83ea84906ecab67c5fcb
1 // Test reading of PCH with changed location of original input files,
2 // i.e. invoking header search.
4 // Generate the original files:
5 // RUN: rm -rf %t_orig %t_moved
6 // RUN: mkdir -p %t_orig/sub %t_orig/sub2
7 // RUN: echo 'struct orig_sub{char c; int i; };' > %t_orig/sub/orig_sub.h
8 // RUN: echo 'void orig_sub2_1();' > %t_orig/sub2/orig_sub2_1.h
9 // RUN: echo '#include "orig_sub2_1.h"' > %t_orig/sub2/orig_sub2.h
10 // RUN: echo 'template <typename T> void tf() { orig_sub2_1(); T::foo(); }' >> %t_orig/sub2/orig_sub2.h
11 // RUN: echo 'void foo() {}' > %t_orig/tmp2.h
12 // RUN: echo '#include "tmp2.h"' > %t_orig/all.h
13 // RUN: echo '#include "sub/orig_sub.h"' >> %t_orig/all.h
14 // RUN: echo '#include "orig_sub2.h"' >> %t_orig/all.h
15 // RUN: echo 'int all();' >> %t_orig/all.h
17 // This test relies on -Wpadded, which is only implemented for Itanium record
18 // layout.
20 // Generate the PCH:
21 // RUN: cd %t_orig && %clang_cc1 -triple %itanium_abi_triple -x c++ -emit-pch -o all.h.pch -Isub2 all.h
22 // RUN: cp -R %t_orig %t_moved
24 // Check diagnostic with location in original source:
25 // RUN: %clang_cc1 -triple %itanium_abi_triple -include-pch all.h.pch -I%t_moved -I%t_moved/sub2 -Wpadded -emit-llvm-only %s 2> %t.stderr
26 // RUN: grep 'struct orig_sub' %t.stderr
28 // Check diagnostic with 2nd location in original source:
29 // RUN: not %clang_cc1 -triple %itanium_abi_triple -DREDECL -include-pch all.h.pch -I%t_moved -I%t_moved/sub2 -emit-llvm-only %s 2> %t.stderr
30 // RUN: grep 'void foo' %t.stderr
32 // Check diagnostic with instantiation location in original source:
33 // RUN: not %clang_cc1 -triple %itanium_abi_triple -DINSTANTIATION -include-pch all.h.pch -I%t_moved -I%t_moved/sub2 -emit-llvm-only %s 2> %t.stderr
34 // RUN: grep 'orig_sub2_1' %t.stderr
36 void qq(orig_sub) {all();}
38 #ifdef REDECL
39 float foo() {return 0;}
40 #endif
42 #ifdef INSTANTIATION
43 void f() {
44 tf<int>();
46 #endif