xref: /llvm-project/clang/test/Preprocessor/nonportable-include-with-hmap.c (revision fdb83b5055957a578b00d286cd99b6a70b1eaa49)
1 // REQUIRES: shell
2 // REQUIRES: case-insensitive-filesystem
3 
4 // RUN: rm -f %t.hmap
5 // RUN: sed -e "s:INPUTS_DIR:%S/Inputs:g" \
6 // RUN:   %S/Inputs/nonportable-hmaps/foo.hmap.json > %t.hmap.json
7 // RUN: %hmaptool write %t.hmap.json %t.hmap
8 // RUN: %clang_cc1 -Eonly                        \
9 // RUN:   -I%t.hmap \
10 // RUN:   -I%S/Inputs/nonportable-hmaps          \
11 // RUN:   %s -verify
12 //
13 // foo.hmap contains: Foo/Foo.h -> headers/foo/Foo.h
14 //
15 // Header search of "Foo/Foo.h" follows this path:
16 //  1. Look for "Foo/Foo.h".
17 //  2. Find "Foo/Foo.h" in "nonportable-hmaps/foo.hmap".
18 //  3. Look for "headers/foo/Foo.h".
19 //  4. Find "headers/foo/Foo.h" in "nonportable-hmaps".
20 //  5. Return.
21 //
22 // There is nothing nonportable; -Wnonportable-include-path should not fire.
23 #include "Foo/Foo.h" // no warning
24 
25 // Verify files with absolute paths in the header map are handled too.
26 // "Bar.h" is included twice to make sure that when we see potentially
27 // nonportable path, the file has been already discovered through a relative
28 // path which triggers the file to be opened and `FileEntry::RealPathName`
29 // to be set.
30 #include "Bar.h"
31 #include "Foo/Bar.h" // no warning
32 
33 // But the presence of the absolute path in the header map is not enough. If we
34 // didn't use it to discover a file, shouldn't suppress the warning.
35 #include "headers/Foo/Baz.h" // expected-warning {{non-portable path}}
36