Skip to content

Commit 2470d27

Browse files
author
git apple-llvm automerger
committed
Merge commit 'b0997e1c1254' from swift/release/6.0 into stable/20230725
2 parents 1d8b970 + b0997e1 commit 2470d27

File tree

5 files changed

+58
-7
lines changed

5 files changed

+58
-7
lines changed

clang/include/clang-c/Dependencies.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,8 +550,20 @@ CINDEX_LINKAGE CXCStringArray
550550
CINDEX_LINKAGE CXCStringArray
551551
clang_experimental_DepGraphModule_getBuildArguments(CXDepGraphModule);
552552

553+
/**
554+
* @returns the CASID of the include-tree for this module, if any.
555+
*
556+
* The string is only valid to use while the \c CXDepGraphModule object is
557+
* valid.
558+
*/
559+
CINDEX_LINKAGE const char *
560+
clang_experimental_DepGraphModule_getIncludeTreeID(CXDepGraphModule);
561+
553562
/**
554563
* \returns the \c ActionCache key for this module, if any.
564+
*
565+
* The string is only valid to use while the \c CXDepGraphModule object is
566+
* valid.
555567
*/
556568
CINDEX_LINKAGE
557569
const char *clang_experimental_DepGraphModule_getCacheKey(CXDepGraphModule);
@@ -596,6 +608,9 @@ CINDEX_LINKAGE CXCStringArray
596608

597609
/**
598610
* \returns the \c ActionCache key for this translation unit, if any.
611+
*
612+
* The string is only valid to use while the \c CXDepGraphTUCommand object is
613+
* valid.
599614
*/
600615
CINDEX_LINKAGE const char *
601616
clang_experimental_DepGraphTUCommand_getCacheKey(CXDepGraphTUCommand);
@@ -619,6 +634,14 @@ CXCStringArray clang_experimental_DepGraph_getTUFileDeps(CXDepGraph);
619634
CINDEX_LINKAGE
620635
CXCStringArray clang_experimental_DepGraph_getTUModuleDeps(CXDepGraph);
621636

637+
/**
638+
* @returns the CASID of the include-tree for this TU, if any.
639+
*
640+
* The string is only valid to use while the \c CXDepGraph object is valid.
641+
*/
642+
CINDEX_LINKAGE
643+
const char *clang_experimental_DepGraph_getTUIncludeTreeID(CXDepGraph);
644+
622645
/**
623646
* \returns the context hash of the C++20 module this translation unit exports.
624647
*

clang/test/Index/Core/scan-deps-cas.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
// INCLUDE_TREE-NEXT: name: ModA
7272
// INCLUDE_TREE-NEXT: context-hash: [[HASH_MOD_A:[A-Z0-9]+]]
7373
// INCLUDE_TREE-NEXT: module-map-path: [[PREFIX]]/Inputs/module/module.modulemap
74+
// INCLUDE_TREE-NEXT: include-tree-id: [[ModA_INCLUDE_TREE_ID:llvmcas://[[:xdigit:]]+]]
7475
// INCLUDE_TREE-NEXT: cache-key: [[ModA_CACHE_KEY:llvmcas://[[:xdigit:]]+]]
7576
// INCLUDE_TREE-NEXT: module-deps:
7677
// INCLUDE_TREE-NEXT: file-deps:
@@ -81,12 +82,13 @@
8182
// INCLUDE_TREE-NEXT: build-args:
8283
// INCLUDE_TREE-SAME: -cc1
8384
// INCLUDE_TREE-SAME: -fcas-path
84-
// INCLUDE_TREE-SAME: -fcas-include-tree llvmcas://{{[[:xdigit:]]+}}
85+
// INCLUDE_TREE-SAME: -fcas-include-tree [[ModA_INCLUDE_TREE_ID]]
8586
// INCLUDE_TREE-SAME: -fcache-compile-job
8687

8788
// INCLUDE_TREE: dependencies:
8889
// INCLUDE_TREE-NEXT: command 0:
8990
// INCLUDE_TREE-NEXT: context-hash: [[HASH_TU:[A-Z0-9]+]]
91+
// INCLUDE_TREE-NEXT: include-tree-id: [[INC_TU_INCLUDE_TREE_ID:llvmcas://[[:xdigit:]]+]]
9092
// INCLUDE_TREE-NEXT: cache-key: [[INC_TU_CACHE_KEY:llvmcas://[[:xdigit:]]+]]
9193
// INCLUDE_TREE-NEXT: module-deps:
9294
// INCLUDE_TREE-NEXT: ModA:[[HASH_MOD_A]]
@@ -95,7 +97,7 @@
9597
// INCLUDE_TREE-NEXT: build-args:
9698
// INCLUDE_TREE-SAME: -cc1
9799
// INCLUDE_TREE-SAME: -fcas-path
98-
// INCLUDE_TREE-SAME: -fcas-include-tree llvmcas://{{[[:xdigit:]]+}}
100+
// INCLUDE_TREE-SAME: -fcas-include-tree [[INC_TU_INCLUDE_TREE_ID]]
99101
// INCLUDE_TREE-SAME: -fcache-compile-job
100102
// INCLUDE_TREE-SAME: -fmodule-file-cache-key [[PCM:.*ModA_.*pcm]] [[ModA_CACHE_KEY]]
101-
// INCLUDE_TREE-SAME: -fmodule-file={{(ModA=)?}}[[PCM]]
103+
// INCLUDE_TREE-SAME: -fmodule-file={{(ModA=)?}}[[PCM]]

clang/tools/c-index-test/core_main.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -760,11 +760,13 @@ static int scanDeps(ArrayRef<const char *> Args, std::string WorkingDirectory,
760760
char *Output, size_t MaxLen)>(LookupOutput);
761761

762762
unsigned CommandIndex = 0;
763-
auto HandleCommand = [&](const char *ContextHash, CXCStringArray ModuleDeps,
764-
CXCStringArray FileDeps, CXCStringArray Args,
765-
const char *CacheKey) {
763+
auto HandleCommand = [&](const char *ContextHash, const char *IncludeTreeID,
764+
CXCStringArray ModuleDeps, CXCStringArray FileDeps,
765+
CXCStringArray Args, const char *CacheKey) {
766766
llvm::outs() << " command " << CommandIndex++ << ":\n";
767767
llvm::outs() << " context-hash: " << ContextHash << "\n";
768+
if (IncludeTreeID)
769+
llvm::outs() << " include-tree-id: " << IncludeTreeID << "\n";
768770
if (CacheKey)
769771
llvm::outs() << " cache-key: " << CacheKey << "\n";
770772
llvm::outs() << " module-deps:\n";
@@ -805,6 +807,8 @@ static int scanDeps(ArrayRef<const char *> Args, std::string WorkingDirectory,
805807
clang_experimental_DepGraphModule_getContextHash(Mod);
806808
const char *ModuleMapPath =
807809
clang_experimental_DepGraphModule_getModuleMapPath(Mod);
810+
const char *ModuleIncludeTreeID =
811+
clang_experimental_DepGraphModule_getIncludeTreeID(Mod);
808812
const char *ModuleCacheKey =
809813
clang_experimental_DepGraphModule_getCacheKey(Mod);
810814
CXCStringArray ModuleDeps =
@@ -820,6 +824,8 @@ static int scanDeps(ArrayRef<const char *> Args, std::string WorkingDirectory,
820824
<< " context-hash: " << ContextHash << "\n"
821825
<< " module-map-path: "
822826
<< (ModuleMapPath ? ModuleMapPath : "<none>") << "\n";
827+
if (ModuleIncludeTreeID)
828+
llvm::outs() << " include-tree-id: " << ModuleIncludeTreeID << "\n";
823829
if (ModuleCacheKey)
824830
llvm::outs() << " cache-key: " << ModuleCacheKey << "\n";
825831
llvm::outs() << " module-deps:\n";
@@ -837,6 +843,8 @@ static int scanDeps(ArrayRef<const char *> Args, std::string WorkingDirectory,
837843
}
838844

839845
llvm::outs() << "dependencies:\n";
846+
const char *TUIncludeTreeID =
847+
clang_experimental_DepGraph_getTUIncludeTreeID(Graph);
840848
const char *TUContextHash =
841849
clang_experimental_DepGraph_getTUContextHash(Graph);
842850
CXCStringArray TUModuleDeps =
@@ -853,7 +861,8 @@ static int scanDeps(ArrayRef<const char *> Args, std::string WorkingDirectory,
853861
clang_experimental_DepGraphTUCommand_getCacheKey(Cmd);
854862
auto Dispose = llvm::make_scope_exit(
855863
[&]() { clang_experimental_DepGraphTUCommand_dispose(Cmd); });
856-
HandleCommand(TUContextHash, TUModuleDeps, TUFileDeps, Args, CacheKey);
864+
HandleCommand(TUContextHash, TUIncludeTreeID, TUModuleDeps, TUFileDeps,
865+
Args, CacheKey);
857866
}
858867
return 0;
859868
}

clang/tools/libclang/CDependencies.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,14 @@ clang_experimental_DepGraphModule_getBuildArguments(CXDepGraphModule CXDepMod) {
596596
ModDeps.getBuildArguments());
597597
}
598598

599+
const char *
600+
clang_experimental_DepGraphModule_getIncludeTreeID(CXDepGraphModule CXDepMod) {
601+
ModuleDeps &ModDeps = *unwrap(CXDepMod)->ModDeps;
602+
if (ModDeps.IncludeTreeID)
603+
return ModDeps.IncludeTreeID->c_str();
604+
return nullptr;
605+
}
606+
599607
const char *
600608
clang_experimental_DepGraphModule_getCacheKey(CXDepGraphModule CXDepMod) {
601609
ModuleDeps &ModDeps = *unwrap(CXDepMod)->ModDeps;
@@ -653,6 +661,13 @@ CXCStringArray clang_experimental_DepGraph_getTUModuleDeps(CXDepGraph Graph) {
653661
return unwrap(Graph)->StrMgr.createCStringsOwned(std::move(Modules));
654662
}
655663

664+
const char *clang_experimental_DepGraph_getTUIncludeTreeID(CXDepGraph Graph) {
665+
TranslationUnitDeps &TUDeps = unwrap(Graph)->TUDeps;
666+
if (TUDeps.IncludeTreeID)
667+
return TUDeps.IncludeTreeID->c_str();
668+
return nullptr;
669+
}
670+
656671
const char *clang_experimental_DepGraph_getTUContextHash(CXDepGraph Graph) {
657672
TranslationUnitDeps &TUDeps = unwrap(Graph)->TUDeps;
658673
return TUDeps.ID.ContextHash.c_str();

clang/tools/libclang/libclang.map

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,12 +523,14 @@ LLVM_16 {
523523
clang_experimental_DepGraph_getTUCommand;
524524
clang_experimental_DepGraph_getTUContextHash;
525525
clang_experimental_DepGraph_getTUFileDeps;
526+
clang_experimental_DepGraph_getTUIncludeTreeID;
526527
clang_experimental_DepGraph_getTUModuleDeps;
527528
clang_experimental_DepGraphModule_dispose;
528529
clang_experimental_DepGraphModule_getBuildArguments;
529530
clang_experimental_DepGraphModule_getCacheKey;
530531
clang_experimental_DepGraphModule_getContextHash;
531532
clang_experimental_DepGraphModule_getFileDeps;
533+
clang_experimental_DepGraphModule_getIncludeTreeID;
532534
clang_experimental_DepGraphModule_getModuleDeps;
533535
clang_experimental_DepGraphModule_getModuleMapPath;
534536
clang_experimental_DepGraphModule_getName;

0 commit comments

Comments
 (0)