Debian Codegraph @

clang/test/VFS/fallback.c

raw
1 // RUN: rm -rf %t
2 // RUN: split-file %s %t
3
4 // Test fallback directory remapping, ie. a directory "Base" which is used as
5 // a fallback if files are missing from "UseFirst"
6
7 // RUN: sed -e "s@EXTERNAL_DIR@%{/t:regex_replacement}/Both/Base@g" -e "s@NAME_DIR@%{/t:regex_replacement}/Both/UseFirst@g" %t/vfs/base.yaml > %t/vfs/both.yaml
8
9 // RUN: cp -R %t/Both %t/UseFirstOnly
10 // RUN: rm -rf %t/UseFirstOnly/Base
11 // RUN: sed -e "s@EXTERNAL_DIR@%{/t:regex_replacement}/UseFirstOnly/Base@g" -e "s@NAME_DIR@%{/t:regex_replacement}/UseFirstOnly/UseFirst@g" %t/vfs/base.yaml > %t/vfs/use-first-only.yaml
12
13 // RUN: cp -R %t/Both %t/BaseOnly
14 // RUN: rm -rf %t/BaseOnly/UseFirst
15 // RUN: sed -e "s@EXTERNAL_DIR@%{/t:regex_replacement}/BaseOnly/Base@g" -e "s@NAME_DIR@%{/t:regex_replacement}/BaseOnly/UseFirst@g" %t/vfs/base.yaml > %t/vfs/base-only.yaml
16
17 // RUN: cp -R %t/Both %t/BFallback
18 // RUN: rm %t/BFallback/UseFirst/B.h
19 // RUN: sed -e "s@EXTERNAL_DIR@%{/t:regex_replacement}/BFallback/Base@g" -e "s@NAME_DIR@%{/t:regex_replacement}/BFallback/UseFirst@g" %t/vfs/base.yaml > %t/vfs/b-fallback.yaml
20
21 // RUN: cp -R %t/Both %t/CFallback
22 // RUN: rm %t/CFallback/UseFirst/C.h
23 // RUN: sed -e "s@EXTERNAL_DIR@%{/t:regex_replacement}/CFallback/Base@g" -e "s@NAME_DIR@%{/t:regex_replacement}/CFallback/UseFirst@g" %t/vfs/base.yaml > %t/vfs/c-fallback.yaml
24
25 // Both B.h and C.h are in both folders
26 // RUN: %clang_cc1 -Werror -I %t/Both/UseFirst -ivfsoverlay %t/vfs/both.yaml -E -C %t/main.c 2>&1 | FileCheck --check-prefix=IN_UF %s
27
28 // IN_UF: # 1 "{{.*(/|\\\\)UseFirst(/|\\\\)}}B.h"
29 // IN_UF-NEXT: // B.h in UseFirst
30 // IN_UF: # 1 "{{.*(/|\\\\)UseFirst(/|\\\\)}}C.h"
31 // IN_UF-NEXT: // C.h in UseFirst
32
33 // Base missing, so now they are only in UseFirst
34 // RUN: %clang_cc1 -Werror -I %t/UseFirstOnly/UseFirst -ivfsoverlay %t/vfs/use-first-only.yaml -E -C %t/main.c 2>&1 | FileCheck --check-prefix=IN_UF %s
35
36 // UseFirst missing, fallback to Base
37 // RUN: %clang_cc1 -Werror -I %t/BaseOnly/UseFirst -ivfsoverlay %t/vfs/base-only.yaml -E -C %t/main.c 2>&1 | FileCheck --check-prefix=IN_BASE %s
38
39 // IN_BASE: # 1 "{{.*(/|\\\\)Base(/|\\\\)}}B.h"
40 // IN_BASE-NEXT: // B.h in Base
41 // IN_BASE: # 1 "{{.*(/|\\\\)Base(/|\\\\)}}C.h"
42 // IN_BASE-NEXT: // C.h in Base
43
44 // B.h missing from UseFirst
45 // RUN: %clang_cc1 -Werror -I %t/BFallback/UseFirst -ivfsoverlay %t/vfs/b-fallback.yaml -E -C %t/main.c 2>&1 | FileCheck --check-prefix=B_FALLBACK %s
46
47 // B_FALLBACK: # 1 "{{.*(/|\\\\)Base(/|\\\\)}}B.h"
48 // B_FALLBACK-NEXT: // B.h in Base
49 // B_FALLBACK: # 1 "{{.*(/|\\\\)UseFirst(/|\\\\)}}C.h"
50 // B_FALLBACK-NEXT: // C.h in UseFirst
51
52 // C.h missing from UseFirst
53 // RUN: %clang_cc1 -Werror -I %t/CFallback/UseFirst -ivfsoverlay %t/vfs/c-fallback.yaml -E -C %t/main.c 2>&1 | FileCheck --check-prefix=C_FALLBACK %s
54
55 // C_FALLBACK: # 1 "{{.*(/|\\\\)UseFirst(/|\\\\)}}B.h"
56 // C_FALLBACK-NEXT: // B.h in UseFirst
57 // C_FALLBACK: # 1 "{{.*(/|\\\\)Base(/|\\\\)}}C.h"
58 // C_FALLBACK-NEXT: // C.h in Base
59
60 //--- main.c
61 #include "B.h"
62
63 //--- Both/UseFirst/B.h
64 // B.h in UseFirst
65 #include "C.h"
66
67 //--- Both/UseFirst/C.h
68 // C.h in UseFirst
69
70 //--- Both/Base/B.h
71 // B.h in Base
72 #include "C.h"
73
74 //--- Both/Base/C.h
75 // C.h in Base
76
77 //--- vfs/base.yaml
78 {
79 'version' : 0,
80 'redirecting-with' : 'fallback',
81 'roots' : [
82 {'name' : 'NAME_DIR',
83 'type' : 'directory-remap',
84 'external-contents' : 'EXTERNAL_DIR'}
85 ]
86 }