@@ -398,10 +398,11 @@ StringRef DirectoryLookup::getName() const {
398
398
Optional<FileEntryRef> HeaderSearch::getFileAndSuggestModule (
399
399
StringRef FileName, SourceLocation IncludeLoc, const DirectoryEntry *Dir,
400
400
bool IsSystemHeaderDir, Module *RequestingModule,
401
- ModuleMap::KnownHeader *SuggestedModule) {
401
+ ModuleMap::KnownHeader *SuggestedModule, bool OpenFile /* =true*/ ,
402
+ bool CacheFailures /* =true*/ ) {
402
403
// If we have a module map that might map this header, load it and
403
404
// check whether we'll have a suggestion for a module.
404
- auto File = getFileMgr ().getFileRef (FileName, /* OpenFile= */ true );
405
+ auto File = getFileMgr ().getFileRef (FileName, OpenFile, CacheFailures );
405
406
if (!File) {
406
407
// For rare, surprising errors (e.g. "out of file handles"), diag the EC
407
408
// message.
@@ -431,7 +432,8 @@ Optional<FileEntryRef> DirectoryLookup::LookupFile(
431
432
SmallVectorImpl<char > *SearchPath, SmallVectorImpl<char > *RelativePath,
432
433
Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule,
433
434
bool &InUserSpecifiedSystemFramework, bool &IsFrameworkFound,
434
- bool &IsInHeaderMap, SmallVectorImpl<char > &MappedName) const {
435
+ bool &IsInHeaderMap, SmallVectorImpl<char > &MappedName,
436
+ bool OpenFile) const {
435
437
InUserSpecifiedSystemFramework = false ;
436
438
IsInHeaderMap = false ;
437
439
MappedName.clear ();
@@ -451,9 +453,9 @@ Optional<FileEntryRef> DirectoryLookup::LookupFile(
451
453
RelativePath->append (Filename.begin (), Filename.end ());
452
454
}
453
455
454
- return HS.getFileAndSuggestModule (TmpDir, IncludeLoc, getDir (),
455
- isSystemHeaderDirectory (),
456
- RequestingModule, SuggestedModule);
456
+ return HS.getFileAndSuggestModule (
457
+ TmpDir, IncludeLoc, getDir (), isSystemHeaderDirectory (),
458
+ RequestingModule, SuggestedModule, OpenFile );
457
459
}
458
460
459
461
if (isFramework ())
@@ -491,7 +493,7 @@ Optional<FileEntryRef> DirectoryLookup::LookupFile(
491
493
Dest = HM->lookupFilename (Filename, Path);
492
494
}
493
495
494
- if (auto Res = HS.getFileMgr ().getOptionalFileRef (Dest)) {
496
+ if (auto Res = HS.getFileMgr ().getOptionalFileRef (Dest, OpenFile )) {
495
497
FixupSearchPath ();
496
498
return *Res;
497
499
}
@@ -840,7 +842,7 @@ Optional<FileEntryRef> HeaderSearch::LookupFile(
840
842
SmallVectorImpl<char > *SearchPath, SmallVectorImpl<char > *RelativePath,
841
843
Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule,
842
844
bool *IsMapped, bool *IsFrameworkFound, bool SkipCache,
843
- bool BuildSystemModule) {
845
+ bool BuildSystemModule, bool OpenFile, bool CacheFailures ) {
844
846
ConstSearchDirIterator CurDirLocal = nullptr ;
845
847
ConstSearchDirIterator &CurDir = CurDirArg ? *CurDirArg : CurDirLocal;
846
848
@@ -869,8 +871,9 @@ Optional<FileEntryRef> HeaderSearch::LookupFile(
869
871
}
870
872
// Otherwise, just return the file.
871
873
return getFileAndSuggestModule (Filename, IncludeLoc, nullptr ,
872
- /* IsSystemHeaderDir*/ false ,
873
- RequestingModule, SuggestedModule);
874
+ /* IsSystemHeaderDir*/ false ,
875
+ RequestingModule, SuggestedModule, OpenFile,
876
+ CacheFailures);
874
877
}
875
878
876
879
// This is the header that MSVC's header search would have found.
@@ -1010,7 +1013,7 @@ Optional<FileEntryRef> HeaderSearch::LookupFile(
1010
1013
Optional<FileEntryRef> File = It->LookupFile (
1011
1014
Filename, *this , IncludeLoc, SearchPath, RelativePath, RequestingModule,
1012
1015
SuggestedModule, InUserSpecifiedSystemFramework, IsFrameworkFoundInDir,
1013
- IsInHeaderMap, MappedName);
1016
+ IsInHeaderMap, MappedName, OpenFile );
1014
1017
if (!MappedName.empty ()) {
1015
1018
assert (IsInHeaderMap && " MappedName should come from a header map" );
1016
1019
CacheLookup.MappedName =
0 commit comments