Skip to content

Commit 98c8b42

Browse files
committed
[DependencyScanning] Count target variant, clang target, and sdk versions as components of scanning context hash
1 parent 62b26b1 commit 98c8b42

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

include/swift/Basic/LangOptions.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,16 @@ namespace swift {
631631
/// Return a hash code of any components from these options that should
632632
/// contribute to a Swift Dependency Scanning hash.
633633
llvm::hash_code getModuleScanningHashComponents() const {
634-
return getPCHHashComponents();
634+
auto hashValue = getPCHHashComponents();
635+
if (TargetVariant.hasValue())
636+
hashValue = llvm::hash_combine(hashValue, TargetVariant.getValue().str());
637+
if (ClangTarget.hasValue())
638+
hashValue = llvm::hash_combine(hashValue, ClangTarget.getValue().str());
639+
if (SDKVersion.hasValue())
640+
hashValue = llvm::hash_combine(hashValue, SDKVersion.getValue().getAsString());
641+
if (VariantSDKVersion.hasValue())
642+
hashValue = llvm::hash_combine(hashValue, VariantSDKVersion.getValue().getAsString());
643+
return hashValue;
635644
}
636645

637646
private:

lib/AST/ModuleDependencies.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,10 @@ ModuleDependenciesCache::getDependencyReferencesMap(
426426
ModuleDependenciesCache::ModuleDependenciesCache(
427427
GlobalModuleDependenciesCache &globalCache,
428428
std::string mainScanModuleName,
429-
std::string scanningContextHash)
429+
std::string scannerContextHash)
430430
: globalCache(globalCache),
431431
mainScanModuleName(mainScanModuleName),
432+
scannerContextHash(scannerContextHash),
432433
clangScanningTool(globalCache.clangScanningService) {
433434
globalCache.configureForContextHash(scannerContextHash);
434435
for (auto kind = ModuleDependenciesKind::FirstKind;

0 commit comments

Comments
 (0)