From 44a8f99d197e26232ba97971e5c61ad7b8fe98ce Mon Sep 17 00:00:00 2001 From: Artem Chikin Date: Thu, 8 Dec 2022 14:31:20 -0800 Subject: [PATCH] [DependencyScanning] Count target variant, clang target, and sdk versions as components of scanning context hash Resolves rdar://103093122 --- include/swift/Basic/LangOptions.h | 11 ++++++++++- lib/AST/ModuleDependencies.cpp | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/swift/Basic/LangOptions.h b/include/swift/Basic/LangOptions.h index 1141f0f40ff3b..45ce443630751 100644 --- a/include/swift/Basic/LangOptions.h +++ b/include/swift/Basic/LangOptions.h @@ -631,7 +631,16 @@ namespace swift { /// Return a hash code of any components from these options that should /// contribute to a Swift Dependency Scanning hash. llvm::hash_code getModuleScanningHashComponents() const { - return getPCHHashComponents(); + auto hashValue = getPCHHashComponents(); + if (TargetVariant.hasValue()) + hashValue = llvm::hash_combine(hashValue, TargetVariant.getValue().str()); + if (ClangTarget.hasValue()) + hashValue = llvm::hash_combine(hashValue, ClangTarget.getValue().str()); + if (SDKVersion.hasValue()) + hashValue = llvm::hash_combine(hashValue, SDKVersion.getValue().getAsString()); + if (VariantSDKVersion.hasValue()) + hashValue = llvm::hash_combine(hashValue, VariantSDKVersion.getValue().getAsString()); + return hashValue; } private: diff --git a/lib/AST/ModuleDependencies.cpp b/lib/AST/ModuleDependencies.cpp index 295de505a7f15..7afdc32f2a3c8 100644 --- a/lib/AST/ModuleDependencies.cpp +++ b/lib/AST/ModuleDependencies.cpp @@ -439,9 +439,10 @@ ModuleDependenciesCache::getDependencyReferencesMap( ModuleDependenciesCache::ModuleDependenciesCache( GlobalModuleDependenciesCache &globalCache, std::string mainScanModuleName, - std::string scanningContextHash) + std::string scannerContextHash) : globalCache(globalCache), mainScanModuleName(mainScanModuleName), + scannerContextHash(scannerContextHash), clangScanningTool(globalCache.ClangScanningService) { globalCache.configureForContextHash(scannerContextHash); for (auto kind = ModuleDependenciesKind::FirstKind;