-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[clang module] Current Working Directory Pruning #124786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7060564
Initial implementation of clang modules current working directory pru…
qiongsiwu 1306637
Fix formatting
qiongsiwu 8f79f1b
Adding a test case against command line inputs that contain relative …
qiongsiwu 9e5bb53
Fix a case where the hash should ignore cwd but still includs it thro…
qiongsiwu 7a67409
Address code review comments.
qiongsiwu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,188 @@ | ||
| // Test current directory pruning when computing the context hash. | ||
|
|
||
| // REQUIRES: shell | ||
|
|
||
| // RUN: rm -rf %t | ||
| // RUN: split-file %s %t | ||
| // RUN: sed -e "s|DIR|%/t|g" %t/cdb0.json.in > %t/cdb0.json | ||
| // RUN: sed -e "s|DIR|%/t|g" %t/cdb1.json.in > %t/cdb1.json | ||
| // RUN: sed -e "s|DIR|%/t|g" %t/cdb3.json.in > %t/cdb3.json | ||
| // RUN: sed -e "s|DIR|%/t|g" %t/cdb4.json.in > %t/cdb4.json | ||
| // RUN: sed -e "s|DIR|%/t|g" %t/cdb5.json.in > %t/cdb5.json | ||
| // RUN: clang-scan-deps -compilation-database %t/cdb0.json -format experimental-full > %t/result0.json | ||
| // RUN: clang-scan-deps -compilation-database %t/cdb1.json -format experimental-full > %t/result1.json | ||
| // It is not a typo to use cdb1.json for result2. We intend to use the same | ||
| // compilation database, but different clang-scan-deps optimize-args options. | ||
| // RUN: clang-scan-deps -compilation-database %t/cdb1.json -format experimental-full -optimize-args=header-search,system-warnings,vfs,canonicalize-macros > %t/result2.json | ||
| // RUN: clang-scan-deps -compilation-database %t/cdb3.json -format experimental-full > %t/result3.json | ||
| // RUN: clang-scan-deps -compilation-database %t/cdb4.json -format experimental-full > %t/result4.json | ||
| // RUN: clang-scan-deps -compilation-database %t/cdb5.json -format experimental-full > %t/result5.json | ||
| // RUN: cat %t/result0.json %t/result1.json | FileCheck %s | ||
| // RUN: cat %t/result0.json %t/result2.json | FileCheck %s -check-prefix=SKIPOPT | ||
| // RUN: cat %t/result3.json %t/result4.json | FileCheck %s -check-prefix=RELPATH | ||
| // RUN: cat %t/result0.json %t/result5.json | FileCheck %s | ||
|
|
||
| //--- cdb0.json.in | ||
| [{ | ||
| "directory": "DIR", | ||
| "command": "clang -c DIR/tu.c -fmodules -fmodules-cache-path=DIR/cache -IDIR/include/ -o DIR/tu.o", | ||
| "file": "DIR/tu.c" | ||
| }] | ||
|
|
||
| //--- cdb1.json.in | ||
| [{ | ||
| "directory": "DIR/a", | ||
| "command": "clang -c DIR/tu.c -fmodules -fmodules-cache-path=DIR/cache -IDIR/include/ -o DIR/tu.o", | ||
| "file": "DIR/tu.c" | ||
| }] | ||
|
|
||
| // cdb2 is skipped because we reuse cdb1. | ||
|
|
||
| //--- cdb3.json.in | ||
| [{ | ||
| "directory": "DIR", | ||
| "command": "clang -c DIR/tu.c -fmodules -fmodules-cache-path=DIR/cache -fprebuilt-module-path=.././module -IDIR/include/ -o DIR/tu.o ", | ||
| "file": "DIR/tu.c" | ||
| }] | ||
|
|
||
| //--- cdb4.json.in | ||
| [{ | ||
| "directory": "DIR/a/", | ||
| "command": "clang -c DIR/tu.c -fmodules -fmodules-cache-path=DIR/cache -fprebuilt-module-path=.././module -IDIR/include/ -o DIR/tu.o ", | ||
| "file": "DIR/tu.c" | ||
| }] | ||
|
|
||
| //--- cdb5.json.in | ||
| [{ | ||
| "directory": "DIR", | ||
| "command": "clang -c DIR/tu.c -fmodules -fmodules-cache-path=DIR/cache -IDIR/include/ -Xclang -working-directory=DIR/a/ -o DIR/tu.o", | ||
| "file": "DIR/tu.c" | ||
| }] | ||
|
|
||
| //--- include/module.modulemap | ||
| module mod { | ||
| header "mod.h" | ||
| } | ||
|
|
||
| //--- include/mod.h | ||
|
|
||
| //--- tu.c | ||
| #include "mod.h" | ||
|
|
||
| // Check that result0 and result1/result5 compute the same hash with | ||
| // optimization on. The only difference between result0 and result1/result5 is | ||
| // the compiler's working directory. | ||
| // CHECK: { | ||
| // CHECK-NEXT: "modules": [ | ||
| // CHECK-NEXT: { | ||
| // CHECK-NEXT: "clang-module-deps": [], | ||
| // CHECK: "context-hash": "[[HASH:.*]]", | ||
| // CHECK: } | ||
| // CHECK: "translation-units": [ | ||
| // CHECK: { | ||
| // CHECK: "commands": [ | ||
| // CHECK: { | ||
| // CHECK-NEXT: "clang-context-hash": "{{.*}}", | ||
| // CHECK-NEXT: "clang-module-deps": [ | ||
| // CHECK-NEXT: { | ||
| // CHECK-NEXT: "context-hash": "[[HASH]]", | ||
| // CHECK-NEXT: "module-name": "mod" | ||
| // CHECK: } | ||
| // CHECK: ], | ||
| // CHECK: { | ||
| // CHECK-NEXT: "modules": [ | ||
| // CHECK-NEXT: { | ||
| // CHECK-NEXT: "clang-module-deps": [], | ||
| // CHECK: "context-hash": "[[HASH]]", | ||
| // CHECK: } | ||
| // CHECK: "translation-units": [ | ||
| // CHECK: { | ||
| // CHECK: "commands": [ | ||
| // CHECK: { | ||
| // CHECK-NEXT: "clang-context-hash": "{{.*}}", | ||
| // CHECK-NEXT: "clang-module-deps": [ | ||
| // CHECK-NEXT: { | ||
| // CHECK-NEXT: "context-hash": "[[HASH]]", | ||
| // CHECK-NEXT: "module-name": "mod" | ||
| // CHECK: } | ||
| // CHECK: ], | ||
|
|
||
| // Check that result0 and result2 compute different hashes because | ||
| // the working directory optmization is turned off for result2. | ||
| // SKIPOPT: { | ||
| // SKIPOPT-NEXT: "modules": [ | ||
| // SKIPOPT-NEXT: { | ||
| // SKIPOPT-NEXT: "clang-module-deps": [], | ||
| // SKIPOPT: "context-hash": "[[HASH0:.*]]", | ||
| // SKIPOPT: } | ||
| // SKIPOPT: "translation-units": [ | ||
| // SKIPOPT: { | ||
| // SKIPOPT: "commands": [ | ||
| // SKIPOPT: { | ||
| // SKIPOPT-NEXT: "clang-context-hash": "{{.*}}", | ||
| // SKIPOPT-NEXT: "clang-module-deps": [ | ||
| // SKIPOPT-NEXT: { | ||
| // SKIPOPT-NEXT: "context-hash": "[[HASH0]]", | ||
| // SKIPOPT-NEXT: "module-name": "mod" | ||
| // SKIPOPT: } | ||
| // SKIPOPT: ], | ||
| // SKIPOPT: { | ||
| // SKIPOPT-NEXT: "modules": [ | ||
| // SKIPOPT-NEXT: { | ||
| // SKIPOPT-NEXT: "clang-module-deps": [], | ||
| // SKIPOPT-NOT: "context-hash": "[[HASH0]]", | ||
| // SKIPOPT: "context-hash": "[[HASH2:.*]]", | ||
| // SKIPOPT: } | ||
| // SKIPOPT: "translation-units": [ | ||
| // SKIPOPT: { | ||
| // SKIPOPT: "commands": [ | ||
| // SKIPOPT: { | ||
| // SKIPOPT-NEXT: "clang-context-hash": "{{.*}}", | ||
| // SKIPOPT-NEXT: "clang-module-deps": [ | ||
| // SKIPOPT-NEXT: { | ||
| // SKIPOPT-NOT: "context-hash": "[[HASH0]]", | ||
| // SKIPOPT-NEXT: "context-hash": "[[HASH2]]" | ||
| // SKIPOPT-NEXT: "module-name": "mod" | ||
| // SKIPOPT: } | ||
| // SKIPOPT: ], | ||
|
|
||
| // Check that result3 and result4 contain different hashes because | ||
| // both have a same relative path as a command line input, and | ||
| // they are produced using different compiler working directories. | ||
| // RELPATH: { | ||
| // RELPATH-NEXT: "modules": [ | ||
| // RELPATH-NEXT: { | ||
| // RELPATH-NEXT: "clang-module-deps": [], | ||
| // RELPATH: "context-hash": "[[HASH3:.*]]", | ||
| // RELPATH: } | ||
| // RELPATH: "translation-units": [ | ||
| // RELPATH: { | ||
| // RELPATH: "commands": [ | ||
| // RELPATH: { | ||
| // RELPATH-NEXT: "clang-context-hash": "{{.*}}", | ||
| // RELPATH-NEXT: "clang-module-deps": [ | ||
| // RELPATH-NEXT: { | ||
| // RELPATH-NEXT: "context-hash": "[[HASH3]]", | ||
| // RELPATH-NEXT: "module-name": "mod" | ||
| // RELPATH: } | ||
| // RELPATH: ], | ||
| // RELPATH: { | ||
| // RELPATH-NEXT: "modules": [ | ||
| // RELPATH-NEXT: { | ||
| // RELPATH-NEXT: "clang-module-deps": [], | ||
| // RELPATH-NOT: "context-hash": "[[HASH3]]", | ||
| // RELPATH: "context-hash": "[[HASH4:.*]]", | ||
| // RELPATH: } | ||
| // RELPATH: "translation-units": [ | ||
| // RELPATH: { | ||
| // RELPATH: "commands": [ | ||
| // RELPATH: { | ||
| // RELPATH-NEXT: "clang-context-hash": "{{.*}}", | ||
| // RELPATH-NEXT: "clang-module-deps": [ | ||
| // RELPATH-NEXT: { | ||
| // RELPATH-NOT: "context-hash": "[[HASH3]]", | ||
| // RELPATH-NEXT: "context-hash": "[[HASH4]]" | ||
| // RELPATH-NEXT: "module-name": "mod" | ||
| // RELPATH: } | ||
| // RELPATH: ], | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.