Skip to content

Commit ecff203

Browse files
committed
Fix the following CAS related test for Windows
Clang :: ClangScanDeps/include-tree-working-directory.c
1 parent 6d73002 commit ecff203

14 files changed

+65
-54
lines changed

clang/lib/CAS/IncludeTree.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ IncludeTree::SpuriousImport::create(ObjectStore &DB, ObjectRef ImportRef,
4747
Expected<IncludeTree::File> IncludeTree::File::create(ObjectStore &DB,
4848
StringRef Filename,
4949
ObjectRef Contents) {
50+
// We store the file path into CAS here. Canonicalize it for Windows
51+
// to avoid cache misses due to slash differences
52+
SmallString<256> Storage(Filename);
53+
llvm::sys::path::make_preferred(Storage);
54+
Filename = StringRef(Storage.data(), Storage.size());
5055
auto PathRef = DB.storeFromString({}, Filename);
5156
if (!PathRef)
5257
return PathRef.takeError();
@@ -1000,6 +1005,9 @@ class IncludeTreeFileSystem final : public llvm::cas::CASBackedFileSystem {
10001005
/// \c createIncludeTreeFileSystem.
10011006
void getPath(const Twine &Path, SmallVectorImpl<char> &Out) {
10021007
Path.toVector(Out);
1008+
// Canonicalize paths for Windows to avoid duplicate entries in
1009+
// the Files map.
1010+
llvm::sys::path::make_preferred(Out);
10031011
// Strip dots, but do not eliminate a path consisting only of '.'
10041012
if (Out.size() != 1)
10051013
llvm::sys::path::remove_dots(Out);
@@ -1044,6 +1052,9 @@ class IncludeTreeFileSystem final : public llvm::cas::CASBackedFileSystem {
10441052

10451053
static std::string computeFilename(StringRef Name, IncludeTreeFileSystem &FS) {
10461054
SmallString<128> Filename(Name);
1055+
// Canonicalize paths for Windows to avoid duplicate entries in the
1056+
// Files map.
1057+
llvm::sys::path::make_preferred(Filename);
10471058
assert(Filename != ".");
10481059
llvm::sys::path::remove_dots(Filename);
10491060

clang/test/ClangScanDeps/include-tree-preserve-pch-path.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
// Extract include-tree casid
3131
// RUN: cat %t/tu.rsp | sed -E 's|.*"-fcas-include-tree" "(llvmcas://[[:xdigit:]]+)".*|\1|' > %t/tu.casid
3232

33-
// RUN: clang-cas-test -cas %t/cas -print-include-tree @%t/tu.casid | FileCheck %s -check-prefix=INCLUDE_TREE -DPREFIX=%/t
34-
// INCLUDE_TREE: (PCH) [[PREFIX]]/prefix.pch llvmcas://
33+
// RUN: clang-cas-test -cas %t/cas -print-include-tree @%t/tu.casid | FileCheck %s -check-prefix=INCLUDE_TREE -DPREFIX=%t
34+
// INCLUDE_TREE: (PCH) [[PREFIX]]{{/|\\}}prefix.pch llvmcas://
3535

3636
// RUN: clang-scan-deps -compilation-database %t/cdb_no_preserve.json -format experimental-include-tree-full -cas-path %t/cas > %t/deps_no_preserve.json
3737
// RUN: FileCheck %s -input-file %t/deps_no_preserve.json -DPREFIX=%/t -check-prefix=NO_PRESERVE

clang/test/ClangScanDeps/include-tree-working-directory.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
// CACHE-HIT: remark: compile job cache hit
2121

2222
// RUN: cat %t/tu.rsp | sed -E 's|.*"-fcas-include-tree" "(llvmcas://[[:xdigit:]]+)".*|\1|' > %t/tu.casid
23-
// RUN: clang-cas-test -cas %t/cas -print-include-tree @%t/tu.casid | FileCheck %s -DPREFIX=%/t
23+
// RUN: clang-cas-test -cas %t/cas -print-include-tree @%t/tu.casid | FileCheck %s -DPREFIX=%t
2424

25-
// CHECK: [[PREFIX]]/t.c llvmcas://
25+
// CHECK: [[PREFIX]]{{/|\\}}t.c llvmcas://
2626
// CHECK: 1:1 <built-in> llvmcas://
27-
// CHECK: 2:1 [[PREFIX]]/relative/h1.h llvmcas://
27+
// CHECK: 2:1 [[PREFIX]]{{/|\\}}relative{{/|\\}}h1.h llvmcas://
2828
// CHECK: Files:
29-
// CHECK: [[PREFIX]]/t.c llvmcas://
30-
// CHECK: [[PREFIX]]/relative/h1.h llvmcas://
29+
// CHECK: [[PREFIX]]{{/|\\}}t.c llvmcas://
30+
// CHECK: [[PREFIX]]{{/|\\}}relative{{/|\\}}h1.h llvmcas://
3131

3232
/// Using a different working directory should cache hit as well.
3333
/// FIXME: Working directory affects some codegen options added by clang driver, preserve them to make sure the cache hit.

clang/test/ClangScanDeps/include-tree.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,27 @@
77
// Try again to ensure a pre-populated CASDB doesn't change output.
88
// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-include-tree -cas-path %t/cas > %t/result2.txt
99
// RUN: diff -u %t/result1.txt %t/result2.txt
10-
// RUN: FileCheck %s -input-file %t/result1.txt -DPREFIX=%/t
10+
// RUN: FileCheck %s -input-file %t/result1.txt -DPREFIX=%t
1111

1212
// Make sure order is as expected.
13-
// RUN: FileCheck %s -input-file %t/result1.txt -DPREFIX=%/t -check-prefix ORDER
13+
// RUN: cat %t/result1.txt | %PathSanitizingFileCheck --sanitize PREFIX=%/t %s -check-prefix ORDER
1414

15-
// ORDER: {{.*}} - [[PREFIX]]{{[/\\]}}t.c
16-
// ORDER-NEXT: [[PREFIX]]{{[/\\]}}t.c
15+
// ORDER: {{.*}} - PREFIX{{[/\\]}}t.c
16+
// ORDER-NEXT: PREFIX{{[/\\]}}t.c
1717
// ORDER-NEXT: 1:1 <built-in>
18-
// ORDER-NEXT: [[PREFIX]]{{[/\\]}}top.h
19-
// ORDER-NEXT: [[PREFIX]]{{[/\\]}}n1.h
20-
// ORDER-NEXT: [[PREFIX]]{{[/\\]}}n2.h
21-
// ORDER-NEXT: [[PREFIX]]{{[/\\]}}n3.h
22-
// ORDER-NEXT: [[PREFIX]]{{[/\\]}}n3.h
23-
// ORDER-NEXT: [[PREFIX]]{{[/\\]}}n2.h
18+
// ORDER-NEXT: PREFIX{{[/\\]}}top.h
19+
// ORDER-NEXT: PREFIX{{[/\\]}}n1.h
20+
// ORDER-NEXT: PREFIX{{[/\\]}}n2.h
21+
// ORDER-NEXT: PREFIX{{[/\\]}}n3.h
22+
// ORDER-NEXT: PREFIX{{[/\\]}}n3.h
23+
// ORDER-NEXT: PREFIX{{[/\\]}}n2.h
2424
// ORDER-NEXT: Files:
25-
// ORDER-NEXT: [[PREFIX]]{{[/\\]}}t.c
26-
// ORDER-NEXT: [[PREFIX]]{{[/\\]}}top.h
27-
// ORDER-NEXT: [[PREFIX]]{{[/\\]}}n1.h
28-
// ORDER-NEXT: [[PREFIX]]{{[/\\]}}n2.h
29-
// ORDER-NEXT: [[PREFIX]]{{[/\\]}}n3.h
30-
// ORDER-NOT: [[PREFIX]]
25+
// ORDER-NEXT: PREFIX{{[/\\]}}t.c
26+
// ORDER-NEXT: PREFIX{{[/\\]}}top.h
27+
// ORDER-NEXT: PREFIX{{[/\\]}}n1.h
28+
// ORDER-NEXT: PREFIX{{[/\\]}}n2.h
29+
// ORDER-NEXT: PREFIX{{[/\\]}}n3.h
30+
// ORDER-NOT: PREFIX
3131

3232
// Full dependency output
3333
// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-include-tree-full -cas-path %t/cas > %t/deps.json

clang/test/ClangScanDeps/modules-include-tree-has-include-umbrella-header.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ module Dependency { header "dependency.h" }
5050
// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-include-tree-full -cas-path %t/cas > %t/deps.json
5151
// RUN: %deps-to-rsp %t/deps.json --tu-index 0 > %t/tu.rsp
5252
// RUN: cat %t/tu.rsp | sed -E 's|.*"-fcas-include-tree" "(llvmcas://[[:xdigit:]]+)".*|\1|' > %t/tu.casid
53-
// RUN: clang-cas-test -cas %t/cas -print-include-tree @%t/tu.casid | FileCheck %s -DPREFIX=%/t
53+
// RUN: clang-cas-test -cas %t/cas -print-include-tree @%t/tu.casid | FileCheck %s -DPREFIX=%t
5454

5555
// Let's check that the TU actually imports FW_Private.B instead of treating FW/B.h as textual.
56-
// CHECK: [[PREFIX]]/tu.c llvmcas://
56+
// CHECK: [[PREFIX]]{{/|\\}}tu.c llvmcas://
5757
// CHECK-NEXT: 1:1 <built-in> llvmcas://
5858
// CHECK-NEXT: 2:1 (Module) Poison
5959
// CHECK-NEXT: 7:1 (Module) Import

clang/test/ClangScanDeps/modules-include-tree-implementation-private.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
// RUN: %deps-to-rsp %t/deps.json --tu-index 0 > %t/tu.rsp
1616
// RUN: cat %t/tu.rsp | sed -E 's|.*"-fcas-include-tree" "(llvmcas://[[:xdigit:]]+)".*|\1|' > %t/tu.casid
17-
// RUN: clang-cas-test -cas %t/cas -print-include-tree @%t/tu.casid | FileCheck %s -DPREFIX=%/t
17+
// RUN: clang-cas-test -cas %t/cas -print-include-tree @%t/tu.casid | FileCheck %s -DPREFIX=%t
1818
// RUN: %clang @%t/tu.rsp
1919
//
2020
// RUN: FileCheck %s -input-file=%t/tu.d -check-prefix DEPS
@@ -24,11 +24,11 @@
2424
// DEPS-DAG: Mod.h
2525
// DEPS-DAG: Priv.h
2626

27-
// CHECK: [[PREFIX]]/tu.m llvmcas://
27+
// CHECK: [[PREFIX]]{{/|\\}}tu.m llvmcas://
2828
// CHECK: 1:1 <built-in> llvmcas://
29-
// CHECK: 2:1 [[PREFIX]]/Mod.framework/Headers/Mod.h llvmcas://
29+
// CHECK: 2:1 [[PREFIX]]{{/|\\}}Mod.framework{{/|\\}}Headers{{/|\\}}Mod.h llvmcas://
3030
// CHECK: Submodule: Mod
31-
// CHECK: 3:1 [[PREFIX]]/Mod.framework/PrivateHeaders/Priv.h llvmcas://
31+
// CHECK: 3:1 [[PREFIX]]{{/|\\}}Mod.framework{{/|\\}}PrivateHeaders{{/|\\}}Priv.h llvmcas://
3232
// CHECK: Submodule: Mod_Private
3333
// CHECK: 4:1 (Module for visibility only) Mod
3434
// CHECK: 5:1 (Module for visibility only) Mod_Private
@@ -39,12 +39,12 @@
3939
// CHECK: link Mod (framework)
4040

4141
// CHECK: Files:
42-
// CHECK: [[PREFIX]]/tu.m llvmcas://
43-
// CHECK-NOT: [[PREFIX]]/module.modulemap
44-
// CHECK: [[PREFIX]]/Mod.framework/Headers/Mod.h llvmcas://
45-
// CHECK-NOT: [[PREFIX]]/module.modulemap
46-
// CHECK: [[PREFIX]]/Mod.framework/PrivateHeaders/Priv.h llvmcas://
47-
// CHECK-NOT: [[PREFIX]]/module.modulemap
42+
// CHECK: [[PREFIX]]{{/|\\}}tu.m llvmcas://
43+
// CHECK-NOT: [[PREFIX]]{{/|\\}}module.modulemap
44+
// CHECK: [[PREFIX]]{{/|\\}}Mod.framework{{/|\\}}Headers{{/|\\}}Mod.h llvmcas://
45+
// CHECK-NOT: [[PREFIX]]{{/|\\}}module.modulemap
46+
// CHECK: [[PREFIX]]{{/|\\}}Mod.framework{{/|\\}}PrivateHeaders{{/|\\}}Priv.h llvmcas://
47+
// CHECK-NOT: [[PREFIX]]{{/|\\}}module.modulemap
4848

4949
//--- cdb.json.template
5050
[{

clang/test/ClangScanDeps/modules-include-tree-implementation-transitive.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ module Mod { header "Mod.h" }
3838

3939
// RUN: cat %t/cas-tu.rsp | sed -E 's|.*"-fcas-include-tree" "(llvmcas://[[:xdigit:]]+)".*|\1|' > %t/tu.casid
4040
// RUN: clang-cas-test -cas %t/cas -print-include-tree @%t/tu.casid > %t/tu-include-tree.txt
41-
// RUN: FileCheck %s -input-file %t/tu-include-tree.txt -DPREFIX=%/t
42-
// CHECK: [[PREFIX]]/tu.m llvmcas://
41+
// RUN: FileCheck %s -input-file %t/tu-include-tree.txt -DPREFIX=%t
42+
// CHECK: [[PREFIX]]{{/|\\}}tu.m llvmcas://
4343
// CHECK-NEXT: 1:1 <built-in> llvmcas://
4444
// CHECK-NEXT: 2:1 (Module) Mod
45-
// CHECK-NEXT: 3:1 [[PREFIX]]/frameworks/FW.framework/Headers/Sub.h llvmcas://{{.*}}
45+
// CHECK-NEXT: 3:1 [[PREFIX]]{{/|\\}}frameworks{{/|\\}}FW.framework{{/|\\}}Headers{{/|\\}}Sub.h llvmcas://{{.*}}
4646
// CHECK-NEXT: Submodule: FW
4747

4848
// RUN: %clang @%t/cas-FW.cc1.rsp

clang/test/ClangScanDeps/modules-include-tree-implementation-via-spurious.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ static mod_int x;
6363

6464
// RUN: cat %t/cas-tu.rsp | sed -E 's|.*"-fcas-include-tree" "(llvmcas://[[:xdigit:]]+)".*|\1|' > %t/tu.casid
6565
// RUN: clang-cas-test -cas %t/cas -print-include-tree @%t/tu.casid > %t/tu-include-tree.txt
66-
// RUN: FileCheck %s -input-file %t/tu-include-tree.txt -DPREFIX=%/t
67-
// CHECK: [[PREFIX]]/tu.m llvmcas://
66+
// RUN: FileCheck %s -input-file %t/tu-include-tree.txt -DPREFIX=%t
67+
// CHECK: [[PREFIX]]{{/|\\}}tu.m llvmcas://
6868
// CHECK-NEXT: 1:1 <built-in> llvmcas://
69-
// CHECK-NEXT: 2:1 (Spurious import) (Module) Spurious.Missing [[PREFIX]]/frameworks/Spurious.framework/Headers/Missing.h llvmcas://
69+
// CHECK-NEXT: 2:1 (Spurious import) (Module) Spurious.Missing [[PREFIX]]{{/|\\}}frameworks{{/|\\}}Spurious.framework{{/|\\}}Headers{{/|\\}}Missing.h llvmcas://
7070
// CHECK-NEXT: 3:1 (Module for visibility only) Mod
7171

7272
// RUN: %clang @%t/cas-Mod.cc1.rsp

clang/test/ClangScanDeps/modules-include-tree-implementation.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
// RUN: %deps-to-rsp %t/deps.json --tu-index 0 > %t/tu.rsp
1616
// RUN: cat %t/tu.rsp | sed -E 's|.*"-fcas-include-tree" "(llvmcas://[[:xdigit:]]+)".*|\1|' > %t/tu.casid
17-
// RUN: clang-cas-test -cas %t/cas -print-include-tree @%t/tu.casid | FileCheck %s -DPREFIX=%/t
17+
// RUN: clang-cas-test -cas %t/cas -print-include-tree @%t/tu.casid | FileCheck %s -DPREFIX=%t
1818
// RUN: %clang @%t/tu.rsp
1919

2020
// CHECK: [[PREFIX]]{{[/\\]}}tu.c llvmcas://{{[[:xdigit:]]+}}
@@ -31,9 +31,9 @@
3131

3232
// CHECK: Files:
3333
// CHECK: [[PREFIX]]{{[/\\]}}tu.c llvmcas://{{[[:xdigit:]]+}}
34-
// CHECK-NOT: [[PREFIX]]/module.modulemap
34+
// CHECK-NOT: [[PREFIX]]{{[/\\]}}module.modulemap
3535
// CHECK: [[PREFIX]]{{[/\\]}}Mod.h llvmcas://{{[[:xdigit:]]+}}
36-
// CHECK-NOT: [[PREFIX]]/module.modulemap
36+
// CHECK-NOT: [[PREFIX]]{{[/\\]}}module.modulemap
3737

3838
// RUN: %deps-to-rsp %t/deps.json --tu-index 1 > %t/tu_missing_module.rsp
3939
// RUN: %clang @%t/tu_missing_module.rsp

clang/test/ClangScanDeps/modules-include-tree-inferred.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// RUN: %deps-to-rsp %t/deps.json --module-name Mod > %t/Mod.rsp
1313
// RUN: %deps-to-rsp %t/deps.json --tu-index 0 > %t/tu.rsp
1414
// RUN: cat %t/Mod.rsp | sed -E 's|.*"-fcas-include-tree" "(llvmcas://[[:xdigit:]]+)".*|\1|' > %t/Mod.casid
15-
// RUN: clang-cas-test -cas %t/cas -print-include-tree @%t/Mod.casid | FileCheck %s -DPREFIX=%/t
15+
// RUN: clang-cas-test -cas %t/cas -print-include-tree @%t/Mod.casid | FileCheck %s -DPREFIX=%t
1616
// RUN: %clang @%t/Mod.rsp
1717
// RUN: %clang @%t/tu.rsp
1818

0 commit comments

Comments
 (0)