@@ -1098,9 +1098,9 @@ class ModuleInterfaceLoaderImpl {
1098
1098
requiresOSSAModules);
1099
1099
1100
1100
// Compute the output path if we're loading or emitting a cached module.
1101
- auto expandedName = astDelegate.getCachedOutputPath (
1101
+ auto resolvedOutputPath = astDelegate.getCachedOutputPath (
1102
1102
moduleName, interfacePath, ctx.SearchPathOpts .getSDKPath ());
1103
- auto &cachedOutputPath = expandedName .outputPath ;
1103
+ auto &cachedOutputPath = resolvedOutputPath .outputPath ;
1104
1104
1105
1105
// Try to find the right module for this interface, either alongside it,
1106
1106
// in the cache, or in the prebuilt cache.
@@ -2005,13 +2005,13 @@ InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl(
2005
2005
2006
2006
// / Calculate an output filename in \p genericSubInvocation's cache path that
2007
2007
// / includes a hash of relevant key data.
2008
- InterfaceModuleNameExpander ::ResultTy
2008
+ InterfaceModuleOutputPathResolver ::ResultTy
2009
2009
InterfaceSubContextDelegateImpl::getCachedOutputPath (StringRef moduleName,
2010
2010
StringRef interfacePath,
2011
2011
StringRef sdkPath) {
2012
- InterfaceModuleNameExpander expander (moduleName, interfacePath, sdkPath,
2013
- genericSubInvocation);
2014
- return expander. getExpandedName ();
2012
+ InterfaceModuleOutputPathResolver resolver (moduleName, interfacePath, sdkPath,
2013
+ genericSubInvocation);
2014
+ return resolver. getOutputPath ();
2015
2015
}
2016
2016
2017
2017
std::error_code
@@ -2090,11 +2090,12 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,
2090
2090
}
2091
2091
2092
2092
// Calculate output path of the module.
2093
- auto expandedName = getCachedOutputPath (moduleName, interfacePath, sdkPath);
2093
+ auto resolvedOutputPath =
2094
+ getCachedOutputPath (moduleName, interfacePath, sdkPath);
2094
2095
2095
2096
// If no specific output path is given, use the hashed output path.
2096
2097
if (outputPath.empty ()) {
2097
- outputPath = expandedName .outputPath ;
2098
+ outputPath = resolvedOutputPath .outputPath ;
2098
2099
}
2099
2100
2100
2101
// Configure the outputs in front-end options. There must be an equal number of
@@ -2148,7 +2149,7 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,
2148
2149
}
2149
2150
2150
2151
info.BuildArguments = BuildArgs;
2151
- info.Hash = expandedName .hash ;
2152
+ info.Hash = resolvedOutputPath .hash ;
2152
2153
2153
2154
// Run the action under the sub compiler instance.
2154
2155
return action (info);
@@ -2743,22 +2744,22 @@ std::unique_ptr<ExplicitCASModuleLoader> ExplicitCASModuleLoader::create(
2743
2744
return result;
2744
2745
}
2745
2746
2746
- InterfaceModuleNameExpander ::ResultTy
2747
- InterfaceModuleNameExpander::getExpandedName () {
2748
- if (!expandedName ) {
2749
- expandedName = std::make_unique<ResultTy>();
2750
- auto &outputPath = expandedName ->outputPath ;
2747
+ InterfaceModuleOutputPathResolver ::ResultTy
2748
+ InterfaceModuleOutputPathResolver::getOutputPath () {
2749
+ if (!resolvedOutputPath ) {
2750
+ resolvedOutputPath = std::make_unique<ResultTy>();
2751
+ auto &outputPath = resolvedOutputPath ->outputPath ;
2751
2752
outputPath = CI.getClangModuleCachePath ();
2752
2753
llvm::sys::path::append (outputPath, moduleName);
2753
2754
outputPath.append (" -" );
2754
2755
auto hashStart = outputPath.size ();
2755
2756
outputPath.append (getHash ());
2756
- expandedName ->hash = outputPath.str ().substr (hashStart);
2757
+ resolvedOutputPath ->hash = outputPath.str ().substr (hashStart);
2757
2758
outputPath.append (" ." );
2758
2759
auto outExt = file_types::getExtension (file_types::TY_SwiftModuleFile);
2759
2760
outputPath.append (outExt);
2760
2761
}
2761
- return *expandedName ;
2762
+ return *resolvedOutputPath ;
2762
2763
}
2763
2764
2764
2765
// / Construct a key for the .swiftmodule being generated. There is a
@@ -2771,7 +2772,7 @@ InterfaceModuleNameExpander::getExpandedName() {
2771
2772
// / -- rather than making a new one and potentially filling up the cache
2772
2773
// / with dead entries -- when other factors change, such as the contents of
2773
2774
// / the .swiftinterface input or its dependencies.
2774
- std::string InterfaceModuleNameExpander ::getHash () {
2775
+ std::string InterfaceModuleOutputPathResolver ::getHash () {
2775
2776
// When doing dependency scanning for explicit module, use strict context hash
2776
2777
// to ensure sound module hash.
2777
2778
bool useStrictCacheHash = CI.getFrontendOptions ().RequestedAction ==
@@ -2841,7 +2842,9 @@ std::string InterfaceModuleNameExpander::getHash() {
2841
2842
return llvm::toString (llvm::APInt (64 , H), 36 , /* Signed=*/ false );
2842
2843
}
2843
2844
2844
- void InterfaceModuleNameExpander ::pruneExtraArgs (
2845
+ void InterfaceModuleOutputPathResolver ::pruneExtraArgs (
2845
2846
std::function<void (ArgListTy &)> filter) {
2847
+ assert (!resolvedOutputPath &&
2848
+ " Cannot prune again after the output path has been resolved." );
2846
2849
filter (extraArgs);
2847
2850
}
0 commit comments