File: home-is-cwd-search-paths.c

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (34 lines) | stat: -rw-r--r-- 1,533 bytes parent folder | download | duplicates (8)
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
// This test demonstrates how -fmodule-map-file-home-is-cwd with -fmodules-embed-all-files
// extend the importer search paths by relying on the side effects of pragma diagnostic
// mappings deserialization.

// RUN: rm -rf %t
// RUN: split-file %s %t

//--- dir1/a.modulemap
module a { header "a.h" }
//--- dir1/a.h
#include "search.h"
// The first compilation is configured such that -I search does contain the search.h header.
//--- dir1/search/search.h
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wparentheses"
#pragma clang diagnostic pop
// RUN: cd %t/dir1 && %clang_cc1 -fmodules -I search \
// RUN:   -emit-module -fmodule-name=a a.modulemap -o %t/a.pcm \
// RUN:   -fmodules-embed-all-files -fmodule-map-file-home-is-cwd

//--- dir2/b.modulemap
module b { header "b.h" }
//--- dir2/b.h
#include "search.h" // expected-error{{'search.h' file not found}}
// The second compilation is configured such that -I search is an empty directory.
// However, since b.pcm simply embeds the headers as "search/search.h", this compilation
// ends up seeing it too. This relies solely on ASTReader::ReadPragmaDiagnosticMappings()
// eagerly reading the corresponding INPUT_FILE record before header search happens.
// Removing the eager deserialization makes this header invisible and so does removing
// the pragma directives.
// RUN: mkdir %t/dir2/search
// RUN: cd %t/dir2 && %clang_cc1 -fmodules -I search \
// RUN:   -emit-module -fmodule-name=b b.modulemap -o %t/b.pcm \
// RUN:   -fmodule-file=%t/a.pcm -verify