| 1 |
// This test checks that reusing FileManager produces deterministic results on case-insensitive filesystems. |
| 2 |
|
| 3 |
// RUN: rm -rf %t |
| 4 |
// RUN: split-file %s %t |
| 5 |
|
| 6 |
//--- dir1/arm/lower.h |
| 7 |
//--- dir2/ARM/upper.h |
| 8 |
//--- t1.c |
| 9 |
#include "upper.h" |
| 10 |
//--- t2.c |
| 11 |
#include "arm/lower.h" |
| 12 |
|
| 13 |
//--- cdb.json.template |
| 14 |
[{ |
| 15 |
"directory": "DIR", |
| 16 |
"command": "clang -fsyntax-only DIR/t1.c -I DIR/dir2/ARM -I DIR/dir1", |
| 17 |
"file": "DIR/t1.c" |
| 18 |
},{ |
| 19 |
"directory": "DIR", |
| 20 |
"command": "clang -fsyntax-only DIR/t2.c -I DIR/dir2 -I DIR/dir1", |
| 21 |
"file": "DIR/t2.c" |
| 22 |
}] |
| 23 |
|
| 24 |
//--- cdb-rev.json.template |
| 25 |
[{ |
| 26 |
"directory": "DIR", |
| 27 |
"command": "clang -fsyntax-only DIR/t2.c -I DIR/dir2 -I DIR/dir1", |
| 28 |
"file": "DIR/t2.c" |
| 29 |
},{ |
| 30 |
"directory": "DIR", |
| 31 |
"command": "clang -fsyntax-only DIR/t1.c -I DIR/dir2/ARM -I DIR/dir1", |
| 32 |
"file": "DIR/t1.c" |
| 33 |
}] |
| 34 |
|
| 35 |
// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json |
| 36 |
// RUN: sed -e "s|DIR|%/t|g" %t/cdb-rev.json.template > %t/cdb-rev.json |
| 37 |
|
| 38 |
// RUN: clang-scan-deps -compilation-database=%t/cdb.json -format make -j 1 | sed 's:\\\\\?:/:g' | FileCheck %s |
| 39 |
|
| 40 |
// In the reversed case, Clang starts by scanning "t2.c". When looking up the "arm/lower.h" header, |
| 41 |
// the string is appended to "DIR/dir2". That file ("DIR/dir2/arm/lower.h") doesn't exist, but when |
| 42 |
// learning so, the FileManager stats and caches the parent directory ("DIR/dir2/arm"), using the |
| 43 |
// UID as the key. |
| 44 |
// When scanning "t1.c" later on, the "DIR/dir2/ARM" search directory is assigned the **same** |
| 45 |
// directory entry (with lowercase "arm"), since they share the UID on case-insensitive filesystems. |
| 46 |
// To preserve the correct case throughout the compiler for any file within that directory, it's |
| 47 |
// important to use the spelling actually used, not just the cached one. |
| 48 |
// RUN: clang-scan-deps -compilation-database=%t/cdb-rev.json -format make -j 1 | sed 's:\\\\\?:/:g' | FileCheck %s |
| 49 |
|
| 50 |
// CHECK: ARM/upper.h |