1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
|
// RUN: rm -rf %t && mkdir %t
// Check that search paths used by `#include` and `#include_next` are reported.
//
// RUN: %clang_cc1 -Eonly %s -Rsearch-path-usage \
// RUN: -I%S/Inputs/search-path-usage/a \
// RUN: -I%S/Inputs/search-path-usage/a_next \
// RUN: -I%S/Inputs/search-path-usage/b \
// RUN: -I%S/Inputs/search-path-usage/c \
// RUN: -I%S/Inputs/search-path-usage/d \
// RUN: -DINCLUDE -verify
#ifdef INCLUDE
#include "a.h" // \
// expected-remark-re {{search path used: '{{.*}}/search-path-usage/a'}} \
// expected-remark-re@#a-include-next {{search path used: '{{.*}}/search-path-usage/a_next'}}
#include "d.h" // \
// expected-remark-re {{search path used: '{{.*}}/search-path-usage/d'}}
#endif
// Check that framework search paths are reported.
//
// RUN: %clang_cc1 -Eonly %s -Rsearch-path-usage \
// RUN: -F%S/Inputs/search-path-usage/FwA \
// RUN: -F%S/Inputs/search-path-usage/FwB \
// RUN: -DFRAMEWORK -verify
#ifdef FRAMEWORK
#include "FrameworkA/FrameworkA.h" // \
// expected-remark-re {{search path used: '{{.*}}/search-path-usage/FwA'}}
#endif
// Check that system search paths are reported.
//
// RUN: %clang_cc1 -Eonly %s -Rsearch-path-usage \
// RUN: -isystem %S/Inputs/search-path-usage/b \
// RUN: -isystem %S/Inputs/search-path-usage/d \
// RUN: -DSYSTEM -verify
#ifdef SYSTEM
#include "b.h" // \
// expected-remark-re {{search path used: '{{.*}}/search-path-usage/b'}}
#endif
// Check that sysroot-based search paths are reported.
//
// RUN: %clang_cc1 -Eonly %s -Rsearch-path-usage \
// RUN: -isysroot %S/Inputs/search-path-usage \
// RUN: -iwithsysroot /b \
// RUN: -iwithsysroot /d \
// RUN: -DSYSROOT -verify
#ifdef SYSROOT
#include "d.h" // \
// expected-remark {{search path used: '/d'}}
#endif
// Check that search paths used by `__has_include()` are reported.
//
// RUN: %clang_cc1 -Eonly %s -Rsearch-path-usage \
// RUN: -I%S/Inputs/search-path-usage/b \
// RUN: -I%S/Inputs/search-path-usage/d \
// RUN: -DHAS_INCLUDE -verify
#ifdef HAS_INCLUDE
#if __has_include("b.h") // \
// expected-remark-re {{search path used: '{{.*}}/search-path-usage/b'}}
#endif
#if __has_include("x.h")
#endif
#endif
// Check that search paths used by `#import` are reported.
//
// RUN: %clang_cc1 -Eonly %s -Rsearch-path-usage \
// RUN: -I%S/Inputs/search-path-usage/b \
// RUN: -I%S/Inputs/search-path-usage/d \
// RUN: -DIMPORT -verify
#ifdef IMPORT
#import "d.h" // \
// expected-remark-re {{search path used: '{{.*}}/search-path-usage/d'}}
#endif
// Check that used header maps are reported when the target file exists.
//
// RUN: sed "s|DIR|%/S/Inputs/search-path-usage|g" \
// RUN: %S/Inputs/search-path-usage/b.hmap.json.template > %t/b.hmap.json
// RUN: %hmaptool write %t/b.hmap.json %t/b.hmap
// RUN: %clang_cc1 -Eonly %s -Rsearch-path-usage \
// RUN: -I %t/b.hmap \
// RUN: -I b \
// RUN: -DHMAP -verify
#ifdef HMAP
#include "b.h" // \
// expected-remark-re {{search path used: '{{.*}}/b.hmap'}}
#endif
// Check that unused header map are not reported.
//
// RUN: %clang_cc1 -Eonly %s -Rsearch-path-usage \
// RUN: -I%t/b.hmap \
// RUN: -I%S/Inputs/search-path-usage/d \
// RUN: -DHMAP_NO_MATCH -verify
#ifdef HMAP_NO_MATCH
#include "d.h" // \
// expected-remark-re {{search path used: '{{.*}}/search-path-usage/d'}}
#endif
// Check that used header map is reported even when the target file is missing.
//
// RUN: sed "s|DIR|%/S/Inputs/search-path-usage/missing-subdir|g" \
// RUN: %S/Inputs/search-path-usage/b.hmap.json.template > %t/b-missing.hmap.json
// RUN: %hmaptool write %t/b-missing.hmap.json %t/b-missing.hmap
// RUN: %clang_cc1 -Eonly %s -Rsearch-path-usage \
// RUN: -I %t/b-missing.hmap \
// RUN: -I b \
// RUN: -DHMAP_MATCHED_BUT_MISSING -verify
#ifdef HMAP_MATCHED_BUT_MISSING
#include "b.h" // \
// expected-remark-re {{search path used: '{{.*}}/b-missing.hmap'}} \
// expected-error {{'b.h' file not found}}
#endif
// Check that used header map is reported even when the target file is missing
// and the lookup is initiated by __has_include.
//
// RUN: %clang_cc1 -Eonly %s -Rsearch-path-usage \
// RUN: -I %t/b-missing.hmap \
// RUN: -I b \
// RUN: -DHMAP_MATCHED_BUT_MISSING_IN_HAS_INCLUDE -verify
#ifdef HMAP_MATCHED_BUT_MISSING_IN_HAS_INCLUDE
#if __has_include("b.h") // \
// expected-remark-re {{search path used: '{{.*}}/b-missing.hmap'}}
#endif
#endif
// Check that search paths with module maps are NOT reported.
//
// RUN: mkdir %t/modulemap_abs
// RUN: sed "s|DIR|%/S/Inputs/search-path-usage|g" \
// RUN: %S/Inputs/search-path-usage/modulemap_abs/module.modulemap.template \
// RUN: > %t/modulemap_abs/module.modulemap
// RUN: %clang_cc1 -Eonly %s -Rsearch-path-usage \
// RUN: -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules \
// RUN: -I %t/modulemap_abs \
// RUN: -I %S/Inputs/search-path-usage/a \
// RUN: -DMODMAP_ABS -verify
#ifdef MODMAP_ABS
@import b; // \
// expected-no-diagnostics
#endif
|