@@ -1098,9 +1098,9 @@ class ModuleInterfaceLoaderImpl {
10981098 requiresOSSAModules);
10991099
11001100 // Compute the output path if we're loading or emitting a cached module.
1101- auto expandedName = astDelegate.getCachedOutputPath (
1101+ auto resolvedOutputPath = astDelegate.getCachedOutputPath (
11021102 moduleName, interfacePath, ctx.SearchPathOpts .getSDKPath ());
1103- auto &cachedOutputPath = expandedName .outputPath ;
1103+ auto &cachedOutputPath = resolvedOutputPath .outputPath ;
11041104
11051105 // Try to find the right module for this interface, either alongside it,
11061106 // in the cache, or in the prebuilt cache.
@@ -2005,13 +2005,13 @@ InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl(
20052005
20062006// / Calculate an output filename in \p genericSubInvocation's cache path that
20072007// / includes a hash of relevant key data.
2008- InterfaceModuleNameExpander ::ResultTy
2008+ InterfaceModuleOutputPathResolver ::ResultTy
20092009InterfaceSubContextDelegateImpl::getCachedOutputPath (StringRef moduleName,
20102010 StringRef interfacePath,
20112011 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 ();
20152015}
20162016
20172017std::error_code
@@ -2090,11 +2090,12 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,
20902090 }
20912091
20922092 // Calculate output path of the module.
2093- auto expandedName = getCachedOutputPath (moduleName, interfacePath, sdkPath);
2093+ auto resolvedOutputPath =
2094+ getCachedOutputPath (moduleName, interfacePath, sdkPath);
20942095
20952096 // If no specific output path is given, use the hashed output path.
20962097 if (outputPath.empty ()) {
2097- outputPath = expandedName .outputPath ;
2098+ outputPath = resolvedOutputPath .outputPath ;
20982099 }
20992100
21002101 // Configure the outputs in front-end options. There must be an equal number of
@@ -2148,7 +2149,7 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,
21482149 }
21492150
21502151 info.BuildArguments = BuildArgs;
2151- info.Hash = expandedName .hash ;
2152+ info.Hash = resolvedOutputPath .hash ;
21522153
21532154 // Run the action under the sub compiler instance.
21542155 return action (info);
@@ -2743,22 +2744,22 @@ std::unique_ptr<ExplicitCASModuleLoader> ExplicitCASModuleLoader::create(
27432744 return result;
27442745}
27452746
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 ;
27512752 outputPath = CI.getClangModuleCachePath ();
27522753 llvm::sys::path::append (outputPath, moduleName);
27532754 outputPath.append (" -" );
27542755 auto hashStart = outputPath.size ();
27552756 outputPath.append (getHash ());
2756- expandedName ->hash = outputPath.str ().substr (hashStart);
2757+ resolvedOutputPath ->hash = outputPath.str ().substr (hashStart);
27572758 outputPath.append (" ." );
27582759 auto outExt = file_types::getExtension (file_types::TY_SwiftModuleFile);
27592760 outputPath.append (outExt);
27602761 }
2761- return *expandedName ;
2762+ return *resolvedOutputPath ;
27622763}
27632764
27642765// / Construct a key for the .swiftmodule being generated. There is a
@@ -2771,7 +2772,7 @@ InterfaceModuleNameExpander::getExpandedName() {
27712772// / -- rather than making a new one and potentially filling up the cache
27722773// / with dead entries -- when other factors change, such as the contents of
27732774// / the .swiftinterface input or its dependencies.
2774- std::string InterfaceModuleNameExpander ::getHash () {
2775+ std::string InterfaceModuleOutputPathResolver ::getHash () {
27752776 // When doing dependency scanning for explicit module, use strict context hash
27762777 // to ensure sound module hash.
27772778 bool useStrictCacheHash = CI.getFrontendOptions ().RequestedAction ==
@@ -2841,7 +2842,9 @@ std::string InterfaceModuleNameExpander::getHash() {
28412842 return llvm::toString (llvm::APInt (64 , H), 36 , /* Signed=*/ false );
28422843}
28432844
2844- void InterfaceModuleNameExpander ::pruneExtraArgs (
2845+ void InterfaceModuleOutputPathResolver ::pruneExtraArgs (
28452846 std::function<void (ArgListTy &)> filter) {
2847+ assert (!resolvedOutputPath &&
2848+ " Cannot prune again after the output path has been resolved." );
28462849 filter (extraArgs);
28472850}
0 commit comments