147 lines · plain
1// RUN: rm -rf %t && mkdir %t2 3// Check that search paths used by `#include` and `#include_next` are reported.4//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 -verify12#ifdef INCLUDE13#include "a.h" // \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'}}16#include "d.h" // \17// expected-remark-re {{search path used: '{{.*}}/search-path-usage/d'}}18#endif19 20// Check that framework search paths are reported.21//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 -verify26#ifdef FRAMEWORK27#include "FrameworkA/FrameworkA.h" // \28// expected-remark-re {{search path used: '{{.*}}/search-path-usage/FwA'}}29#endif30 31// Check that system search paths are reported.32//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 -verify37#ifdef SYSTEM38#include "b.h" // \39// expected-remark-re {{search path used: '{{.*}}/search-path-usage/b'}}40#endif41 42// Check that sysroot-based search paths are reported.43//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 -verify49#ifdef SYSROOT50#include "d.h" // \51// expected-remark {{search path used: '/d'}}52#endif53 54// Check that search paths used by `__has_include()` are reported.55//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 -verify60#ifdef HAS_INCLUDE61#if __has_include("b.h") // \62// expected-remark-re {{search path used: '{{.*}}/search-path-usage/b'}}63#endif64#if __has_include("x.h")65#endif66#endif67 68// Check that search paths used by `#import` are reported.69//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 -verify74#ifdef IMPORT75#import "d.h" // \76// expected-remark-re {{search path used: '{{.*}}/search-path-usage/d'}}77#endif78 79// Check that used header maps are reported when the target file exists.80//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.json83// RUN: %hmaptool write %t/b.hmap.json %t/b.hmap84// RUN: %clang_cc1 -Eonly %s -Rsearch-path-usage \85// RUN: -I %t/b.hmap \86// RUN: -I b \87// RUN: -DHMAP -verify88#ifdef HMAP89#include "b.h" // \90// expected-remark-re {{search path used: '{{.*}}/b.hmap'}}91#endif92 93// Check that unused header map are not reported.94//95// RUN: %clang_cc1 -Eonly %s -Rsearch-path-usage \96// RUN: -I%t/b.hmap \97// RUN: -I%S/Inputs/search-path-usage/d \98// RUN: -DHMAP_NO_MATCH -verify99#ifdef HMAP_NO_MATCH100#include "d.h" // \101// expected-remark-re {{search path used: '{{.*}}/search-path-usage/d'}}102#endif103 104// Check that used header map is reported even when the target file is missing.105//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.json108// RUN: %hmaptool write %t/b-missing.hmap.json %t/b-missing.hmap109// RUN: %clang_cc1 -Eonly %s -Rsearch-path-usage \110// RUN: -I %t/b-missing.hmap \111// RUN: -I b \112// RUN: -DHMAP_MATCHED_BUT_MISSING -verify113#ifdef HMAP_MATCHED_BUT_MISSING114#include "b.h" // \115// expected-remark-re {{search path used: '{{.*}}/b-missing.hmap'}} \116// expected-error {{'b.h' file not found}}117#endif118 119// Check that used header map is reported even when the target file is missing120// and the lookup is initiated by __has_include.121//122// RUN: %clang_cc1 -Eonly %s -Rsearch-path-usage \123// RUN: -I %t/b-missing.hmap \124// RUN: -I b \125// RUN: -DHMAP_MATCHED_BUT_MISSING_IN_HAS_INCLUDE -verify126#ifdef HMAP_MATCHED_BUT_MISSING_IN_HAS_INCLUDE127#if __has_include("b.h") // \128// expected-remark-re {{search path used: '{{.*}}/b-missing.hmap'}}129#endif130#endif131 132// Check that search paths with module maps are NOT reported.133//134// RUN: mkdir %t/modulemap_abs135// 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.modulemap138// 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 -verify143#ifdef MODMAP_ABS144@import b; // \145// expected-no-diagnostics146#endif147