@@ -2020,18 +2020,23 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc,
2020
2020
}
2021
2021
};
2022
2022
2023
+ auto CheckLoadResult = [&](ModuleLoadResult Result) {
2024
+ if (Result)
2025
+ return true ;
2026
+ assert (hadModuleLoaderFatalFailure () && " unexpected failure kind" );
2027
+ if (hadModuleLoaderFatalFailure ()) {
2028
+ IncludeTok.setKind (tok::eof);
2029
+ CurLexer->cutOffLexing ();
2030
+ }
2031
+ return false ;
2032
+ };
2033
+
2023
2034
auto LoadModule = [&](const PPCachedActions::IncludeModule *Import) {
2024
2035
auto Imported = TheModuleLoader.loadModule (
2025
2036
IncludeTok.getLocation (), ArrayRef (Import->ImportPath ).take_front (),
2026
2037
Module::Hidden, /* IsInclusionDirective=*/ true );
2027
- if (!Imported) {
2028
- assert (hadModuleLoaderFatalFailure () && " unexpected failure kind" );
2029
- if (hadModuleLoaderFatalFailure ()) {
2030
- IncludeTok.setKind (tok::eof);
2031
- CurLexer->cutOffLexing ();
2032
- }
2038
+ if (!CheckLoadResult (Imported))
2033
2039
return ;
2034
- }
2035
2040
2036
2041
auto Path = Import->ImportPath ;
2037
2042
std::string PathStr = Path.front ().first ->getName ().str ();
@@ -2064,14 +2069,8 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc,
2064
2069
Imported = TheModuleLoader.loadModule (
2065
2070
IncludeTok.getLocation (), Import->ImportPath , Module::Hidden,
2066
2071
/* IsIncludeDirective=*/ true );
2067
- if (!Imported) {
2068
- assert (hadModuleLoaderFatalFailure () && " unexpected failure kind" );
2069
- if (hadModuleLoaderFatalFailure ()) {
2070
- IncludeTok.setKind (tok::eof);
2071
- CurLexer->cutOffLexing ();
2072
- }
2072
+ if (!CheckLoadResult (Imported))
2073
2073
return ;
2074
- }
2075
2074
}
2076
2075
2077
2076
makeModuleVisible (Imported, EndLoc);
0 commit comments