-
Notifications
You must be signed in to change notification settings - Fork 341
[clang dependency scanning] C APIs for Current Working Directory Optimization #10146
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
Changes from all commits
c0801f6
6843dc5
91d25ec
774d7cf
01f93ac
1399861
14403d0
8732c80
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,6 +125,20 @@ CINDEX_LINKAGE void | |
clang_experimental_DependencyScannerServiceOptions_setCASOptions( | ||
CXDependencyScannerServiceOptions Opts, CXCASOptions); | ||
|
||
/** | ||
* Set the working directory optimization option. | ||
* The dependency scanner service option Opts will indicate to the scanner that | ||
* the current working directory can or cannot be ignored when computing the | ||
* pcms' context hashes. The scanner will then determine if it is safe to | ||
* optimize each module and act accordingly. | ||
* | ||
* \param Value If it is non zero, the option is on. Otherwise the | ||
* option is off. | ||
*/ | ||
CINDEX_LINKAGE void | ||
clang_experimental_DependencyScannerServiceOptions_setCWDOptimization( | ||
CXDependencyScannerServiceOptions Opts, int Value); | ||
|
||
/** | ||
* Specify a \c CXCASObjectStore in the given options. If an object store and | ||
* action cache are available, the scanner will produce cached commands. | ||
|
@@ -420,6 +434,13 @@ CINDEX_LINKAGE const char * | |
CINDEX_LINKAGE | ||
const char *clang_experimental_DepGraphModule_getCacheKey(CXDepGraphModule); | ||
|
||
/** | ||
* \returns 1 if the scanner ignores the current working directory when | ||
* computing the module's context hash. Otherwise returns 0. | ||
*/ | ||
CINDEX_LINKAGE | ||
int clang_experimental_DepGraphModule_isCWDIgnored(CXDepGraphModule); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there precedent for "CWD" in the C API layer? Maybe we should spell it out as "WorkingDirectory". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried doing this but |
||
|
||
/** | ||
* \returns the number \c CXDepGraphTUCommand objects in the graph. | ||
*/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Test the current working directory C APIs. | ||
|
||
// RUN: rm -rf %t | ||
// RUN: split-file %s %t | ||
|
||
// RUN: c-index-test core -scan-deps -working-dir %S -- %clang \ | ||
// RUN: -c %t/main.c -fmodules -fmodules-cache-path=%t/module-cache \ | ||
// RUN: 2>&1 > %t/no_cwd_opt.txt | ||
// RUN: cat %t/no_cwd_opt.txt | FileCheck %s --check-prefix=NO-CWD-OPT | ||
|
||
|
||
// RUN: c-index-test core -scan-deps -working-dir %S -optimize-cwd -- \ | ||
// RUN: %clang \ | ||
// RUN: -c %t/main.c -fmodules -fmodules-cache-path=%t/module-cache \ | ||
// RUN: 2>&1 > %t/cwd_opt.txt | ||
// RUN: cat %t/cwd_opt.txt | FileCheck %s --check-prefix=CWD-OPT | ||
|
||
//--- module.modulemap | ||
module Mod { header "Mod.h" } | ||
|
||
//--- Mod.h | ||
int foo(); | ||
|
||
//--- main.c | ||
#include "Mod.h" | ||
|
||
int main() { | ||
return foo(); | ||
} | ||
|
||
// NO-CWD-OPT: modules: | ||
// NO-CWD-OPT-NEXT: module: | ||
// NO-CWD-OPT-NEXT: name: Mod | ||
// NO-CWD-OPT-NEXT: context-hash:{{.*}} | ||
// NO-CWD-OPT-NEXT: cwd-ignored: 0 | ||
|
||
|
||
// CWD-OPT: modules: | ||
// CWD-OPT-NEXT: module: | ||
// CWD-OPT-NEXT: name: Mod | ||
// CWD-OPT-NEXT: context-hash:{{.*}} | ||
// CWD-OPT-NEXT: cwd-ignored: 1 |
Uh oh!
There was an error while loading. Please reload this page.