1 // This test demonstrates how -fmodule-map-file-home-is-cwd with -fmodules-embed-all-files 2 // extend the importer search paths by relying on the side effects of pragma diagnostic 3 // mappings deserialization. 4 5 // RUN: rm -rf %t 6 // RUN: split-file %s %t 7 8 //--- dir1/a.modulemap 9 module a { header "a.h" } 10 //--- dir1/a.h 11 #include "search.h" 12 // The first compilation is configured such that -I search does contain the search.h header. 13 //--- dir1/search/search.h 14 #pragma clang diagnostic push 15 #pragma clang diagnostic ignored "-Wparentheses" 16 #pragma clang diagnostic pop 17 // RUN: cd %t/dir1 && %clang_cc1 -fmodules -I search \ 18 // RUN: -emit-module -fmodule-name=a a.modulemap -o %t/a.pcm \ 19 // RUN: -fmodules-embed-all-files -fmodule-map-file-home-is-cwd 20 21 //--- dir2/b.modulemap 22 module b { header "b.h" } 23 //--- dir2/b.h 24 #include "search.h" // expected-error{{'search.h' file not found}} 25 // The second compilation is configured such that -I search is an empty directory. 26 // However, since b.pcm simply embeds the headers as "search/search.h", this compilation 27 // ends up seeing it too. This relies solely on ASTReader::ReadPragmaDiagnosticMappings() 28 // eagerly reading the corresponding INPUT_FILE record before header search happens. 29 // Removing the eager deserialization makes this header invisible and so does removing 30 // the pragma directives. 31 // RUN: mkdir %t/dir2/search 32 // RUN: cd %t/dir2 && %clang_cc1 -fmodules -I search \ 33 // RUN: -emit-module -fmodule-name=b b.modulemap -o %t/b.pcm \ 34 // RUN: -fmodule-file=%t/a.pcm -verify 35