1 // RUN: rm -rf %t && mkdir %t
3 // Check that search paths used by `#include` and `#include_next` are reported.
5 // RUN: %clang_cc1 -Eonly %s -Rsearch-path-usage \
6 // RUN: -I%S/Inputs/search-path-usage/a \
7 // RUN: -I%S/Inputs/search-path-usage/a_next \
8 // RUN: -I%S/Inputs/search-path-usage/b \
9 // RUN: -I%S/Inputs/search-path-usage/c \
10 // RUN: -I%S/Inputs/search-path-usage/d \
11 // RUN: -DINCLUDE -verify
14 // expected-remark-re {{search path used: '{{.*}}/search-path-usage/a'}} \
15 // expected-remark-re@#a-include-next {{search path used: '{{.*}}/search-path-usage/a_next'}}
17 // expected-remark-re {{search path used: '{{.*}}/search-path-usage/d'}}
20 // Check that framework search paths are reported.
22 // RUN: %clang_cc1 -Eonly %s -Rsearch-path-usage \
23 // RUN: -F%S/Inputs/search-path-usage/FwA \
24 // RUN: -F%S/Inputs/search-path-usage/FwB \
25 // RUN: -DFRAMEWORK -verify
27 #include "FrameworkA/FrameworkA.h" // \
28 // expected-remark-re {{search path used: '{{.*}}/search-path-usage/FwA'}}
31 // Check that system search paths are reported.
33 // RUN: %clang_cc1 -Eonly %s -Rsearch-path-usage \
34 // RUN: -isystem %S/Inputs/search-path-usage/b \
35 // RUN: -isystem %S/Inputs/search-path-usage/d \
36 // RUN: -DSYSTEM -verify
39 // expected-remark-re {{search path used: '{{.*}}/search-path-usage/b'}}
42 // Check that sysroot-based search paths are reported.
44 // RUN: %clang_cc1 -Eonly %s -Rsearch-path-usage \
45 // RUN: -isysroot %S/Inputs/search-path-usage \
46 // RUN: -iwithsysroot /b \
47 // RUN: -iwithsysroot /d \
48 // RUN: -DSYSROOT -verify
51 // expected-remark {{search path used: '/d'}}
54 // Check that search paths used by `__has_include()` are reported.
56 // RUN: %clang_cc1 -Eonly %s -Rsearch-path-usage \
57 // RUN: -I%S/Inputs/search-path-usage/b \
58 // RUN: -I%S/Inputs/search-path-usage/d \
59 // RUN: -DHAS_INCLUDE -verify
61 #if __has_include("b.h") // \
62 // expected-remark-re {{search path used: '{{.*}}/search-path-usage/b'}}
64 #if __has_include("x.h")
68 // Check that search paths used by `#import` are reported.
70 // RUN: %clang_cc1 -Eonly %s -Rsearch-path-usage \
71 // RUN: -I%S/Inputs/search-path-usage/b \
72 // RUN: -I%S/Inputs/search-path-usage/d \
73 // RUN: -DIMPORT -verify
76 // expected-remark-re {{search path used: '{{.*}}/search-path-usage/d'}}
79 // Check that used header maps are reported when the target file exists.
81 // RUN: sed "s|DIR|%/S/Inputs/search-path-usage|g" \
82 // RUN: %S/Inputs/search-path-usage/b.hmap.json.template > %t/b.hmap.json
83 // RUN: %hmaptool write %t/b.hmap.json %t/b.hmap
84 // RUN: %clang_cc1 -Eonly %s -Rsearch-path-usage \
85 // RUN: -I %t/b.hmap \
87 // RUN: -DHMAP -verify
90 // expected-remark-re {{search path used: '{{.*}}/b.hmap'}}
93 // Check that unused header map are not reported.
95 // RUN: %clang_cc1 -Eonly %s -Rsearch-path-usage \
97 // RUN: -I%S/Inputs/search-path-usage/d \
98 // RUN: -DHMAP_NO_MATCH -verify
101 // expected-remark-re {{search path used: '{{.*}}/search-path-usage/d'}}
104 // Check that used header map is reported even when the target file is missing.
106 // RUN: sed "s|DIR|%/S/Inputs/search-path-usage/missing-subdir|g" \
107 // RUN: %S/Inputs/search-path-usage/b.hmap.json.template > %t/b-missing.hmap.json
108 // RUN: %hmaptool write %t/b-missing.hmap.json %t/b-missing.hmap
109 // RUN: %clang_cc1 -Eonly %s -Rsearch-path-usage \
110 // RUN: -I %t/b-missing.hmap \
112 // RUN: -DHMAP_MATCHED_BUT_MISSING -verify
113 #ifdef HMAP_MATCHED_BUT_MISSING
115 // expected-remark-re {{search path used: '{{.*}}/b-missing.hmap'}} \
116 // expected-error {{'b.h' file not found}}
119 // Check that used header map is reported even when the target file is missing
120 // and the lookup is initiated by __has_include.
122 // RUN: %clang_cc1 -Eonly %s -Rsearch-path-usage \
123 // RUN: -I %t/b-missing.hmap \
125 // RUN: -DHMAP_MATCHED_BUT_MISSING_IN_HAS_INCLUDE -verify
126 #ifdef HMAP_MATCHED_BUT_MISSING_IN_HAS_INCLUDE
127 #if __has_include("b.h") // \
128 // expected-remark-re {{search path used: '{{.*}}/b-missing.hmap'}}
132 // Check that search paths with module maps are NOT reported.
134 // RUN: mkdir %t/modulemap_abs
135 // RUN: sed "s|DIR|%/S/Inputs/search-path-usage|g" \
136 // RUN: %S/Inputs/search-path-usage/modulemap_abs/module.modulemap.template \
137 // RUN: > %t/modulemap_abs/module.modulemap
138 // RUN: %clang_cc1 -Eonly %s -Rsearch-path-usage \
139 // RUN: -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules \
140 // RUN: -I %t/modulemap_abs \
141 // RUN: -I %S/Inputs/search-path-usage/a \
142 // RUN: -DMODMAP_ABS -verify
145 // expected-no-diagnostics