@@ -1206,16 +1206,6 @@ compileModuleImpl(CompilerInstance &ImportingInstance, SourceLocation ImportLoc,
1206
1206
// Note the name of the module we're building.
1207
1207
Invocation->getLangOpts ().CurrentModule = std::string (ModuleName);
1208
1208
1209
- // Make sure that the failed-module structure has been allocated in
1210
- // the importing instance, and propagate the pointer to the newly-created
1211
- // instance.
1212
- PreprocessorOptions &ImportingPPOpts
1213
- = ImportingInstance.getInvocation ().getPreprocessorOpts ();
1214
- if (!ImportingPPOpts.FailedModules )
1215
- ImportingPPOpts.FailedModules =
1216
- std::make_shared<PreprocessorOptions::FailedModulesSet>();
1217
- PPOpts.FailedModules = ImportingPPOpts.FailedModules ;
1218
-
1219
1209
// If there is a module map file, build the module using the module map.
1220
1210
// Set up the inputs/outputs so that we build the module from its umbrella
1221
1211
// header.
@@ -1269,6 +1259,13 @@ compileModuleImpl(CompilerInstance &ImportingInstance, SourceLocation ImportLoc,
1269
1259
SourceMgr.pushModuleBuildStack (ModuleName,
1270
1260
FullSourceLoc (ImportLoc, ImportingInstance.getSourceManager ()));
1271
1261
1262
+ // Make sure that the failed-module structure has been allocated in
1263
+ // the importing instance, and propagate the pointer to the newly-created
1264
+ // instance.
1265
+ if (!ImportingInstance.hasFailedModulesSet ())
1266
+ ImportingInstance.createFailedModulesSet ();
1267
+ Instance.setFailedModulesSet (ImportingInstance.getFailedModulesSetPtr ());
1268
+
1272
1269
// If we're collecting module dependencies, we need to share a collector
1273
1270
// between all of the module CompilerInstances. Other than that, we don't
1274
1271
// want to produce any dependency output from the module build.
@@ -1992,10 +1989,8 @@ ModuleLoadResult CompilerInstance::findOrCompileModuleAndReadAST(
1992
1989
return nullptr ;
1993
1990
}
1994
1991
1995
- // Check whether we have already attempted to build this module (but
1996
- // failed).
1997
- if (getPreprocessorOpts ().FailedModules &&
1998
- getPreprocessorOpts ().FailedModules ->hasAlreadyFailed (ModuleName)) {
1992
+ // Check whether we have already attempted to build this module (but failed).
1993
+ if (FailedModules && FailedModules->hasAlreadyFailed (ModuleName)) {
1999
1994
getDiagnostics ().Report (ModuleNameLoc, diag::err_module_not_built)
2000
1995
<< ModuleName << SourceRange (ImportLoc, ModuleNameLoc);
2001
1996
return nullptr ;
@@ -2006,8 +2001,8 @@ ModuleLoadResult CompilerInstance::findOrCompileModuleAndReadAST(
2006
2001
ModuleFilename)) {
2007
2002
assert (getDiagnostics ().hasErrorOccurred () &&
2008
2003
" undiagnosed error in compileModuleAndReadAST" );
2009
- if (getPreprocessorOpts (). FailedModules )
2010
- getPreprocessorOpts (). FailedModules ->addFailed (ModuleName);
2004
+ if (FailedModules)
2005
+ FailedModules->addFailed (ModuleName);
2011
2006
return nullptr ;
2012
2007
}
2013
2008
0 commit comments