1 //===--- HeaderSearch.cpp - Resolve Header File Locations ---===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the DirectoryLookup and HeaderSearch interfaces.
12 //===----------------------------------------------------------------------===//
14 #include "clang/Lex/HeaderSearch.h"
15 #include "clang/Basic/FileManager.h"
16 #include "clang/Basic/IdentifierTable.h"
17 #include "clang/Lex/HeaderMap.h"
18 #include "clang/Lex/HeaderSearchOptions.h"
19 #include "clang/Lex/LexDiagnostic.h"
20 #include "clang/Lex/Lexer.h"
21 #include "llvm/ADT/APInt.h"
22 #include "llvm/ADT/Hashing.h"
23 #include "llvm/ADT/SmallString.h"
24 #include "llvm/Support/Capacity.h"
25 #include "llvm/Support/FileSystem.h"
26 #include "llvm/Support/Path.h"
27 #include "llvm/Support/raw_ostream.h"
29 #if defined(LLVM_ON_UNIX)
32 using namespace clang;
34 const IdentifierInfo *
35 HeaderFileInfo::getControllingMacro(ExternalIdentifierLookup *External) {
37 return ControllingMacro;
39 if (!ControllingMacroID || !External)
42 ControllingMacro = External->GetIdentifier(ControllingMacroID);
43 return ControllingMacro;
46 ExternalHeaderFileInfoSource::~ExternalHeaderFileInfoSource() {}
48 HeaderSearch::HeaderSearch(IntrusiveRefCntPtr<HeaderSearchOptions> HSOpts,
49 SourceManager &SourceMgr, DiagnosticsEngine &Diags,
50 const LangOptions &LangOpts,
51 const TargetInfo *Target)
52 : HSOpts(HSOpts), Diags(Diags), FileMgr(SourceMgr.getFileManager()),
53 FrameworkMap(64), ModMap(SourceMgr, Diags, LangOpts, Target, *this) {
56 NoCurDirSearch = false;
58 ExternalLookup = nullptr;
59 ExternalSource = nullptr;
61 NumMultiIncludeFileOptzn = 0;
62 NumFrameworkLookups = NumSubFrameworkLookups = 0;
64 EnabledModules = LangOpts.Modules;
67 HeaderSearch::~HeaderSearch() {
69 for (unsigned i = 0, e = HeaderMaps.size(); i != e; ++i)
70 delete HeaderMaps[i].second;
73 void HeaderSearch::PrintStats() {
74 fprintf(stderr, "\n*** HeaderSearch Stats:\n");
75 fprintf(stderr, "%d files tracked.\n", (int)FileInfo.size());
76 unsigned NumOnceOnlyFiles = 0, MaxNumIncludes = 0, NumSingleIncludedFiles = 0;
77 for (unsigned i = 0, e = FileInfo.size(); i != e; ++i) {
78 NumOnceOnlyFiles += FileInfo[i].isImport;
79 if (MaxNumIncludes < FileInfo[i].NumIncludes)
80 MaxNumIncludes = FileInfo[i].NumIncludes;
81 NumSingleIncludedFiles += FileInfo[i].NumIncludes == 1;
83 fprintf(stderr, " %d #import/#pragma once files.\n", NumOnceOnlyFiles);
84 fprintf(stderr, " %d included exactly once.\n", NumSingleIncludedFiles);
85 fprintf(stderr, " %d max times a file is included.\n", MaxNumIncludes);
87 fprintf(stderr, " %d #include/#include_next/#import.\n", NumIncluded);
88 fprintf(stderr, " %d #includes skipped due to"
89 " the multi-include optimization.\n", NumMultiIncludeFileOptzn);
91 fprintf(stderr, "%d framework lookups.\n", NumFrameworkLookups);
92 fprintf(stderr, "%d subframework lookups.\n", NumSubFrameworkLookups);
95 /// CreateHeaderMap - This method returns a HeaderMap for the specified
96 /// FileEntry, uniquing them through the 'HeaderMaps' datastructure.
97 const HeaderMap *HeaderSearch::CreateHeaderMap(const FileEntry *FE) {
98 // We expect the number of headermaps to be small, and almost always empty.
99 // If it ever grows, use of a linear search should be re-evaluated.
100 if (!HeaderMaps.empty()) {
101 for (unsigned i = 0, e = HeaderMaps.size(); i != e; ++i)
102 // Pointer equality comparison of FileEntries works because they are
103 // already uniqued by inode.
104 if (HeaderMaps[i].first == FE)
105 return HeaderMaps[i].second;
108 if (const HeaderMap *HM = HeaderMap::Create(FE, FileMgr)) {
109 HeaderMaps.push_back(std::make_pair(FE, HM));
116 std::string HeaderSearch::getModuleFileName(Module *Module) {
117 return getModuleFileName(Module->Name, Module->ModuleMap->getName());
120 std::string HeaderSearch::getModuleFileName(StringRef ModuleName,
121 StringRef ModuleMapPath) {
122 // If we don't have a module cache path, we can't do anything.
123 if (ModuleCachePath.empty())
124 return std::string();
126 SmallString<256> Result(ModuleCachePath);
127 llvm::sys::fs::make_absolute(Result);
129 if (HSOpts->DisableModuleHash) {
130 llvm::sys::path::append(Result, ModuleName + ".pcm");
132 // Construct the name <ModuleName>-<hash of ModuleMapPath>.pcm which should
133 // be globally unique to this particular module. To avoid false-negatives
134 // on case-insensitive filesystems, we use lower-case, which is safe because
135 // to cause a collision the modules must have the same name, which is an
136 // error if they are imported in the same translation.
137 SmallString<256> AbsModuleMapPath(ModuleMapPath);
138 llvm::sys::fs::make_absolute(AbsModuleMapPath);
139 llvm::APInt Code(64, llvm::hash_value(AbsModuleMapPath.str().lower()));
140 SmallString<128> HashStr;
141 Code.toStringUnsigned(HashStr, /*Radix*/36);
142 llvm::sys::path::append(Result, ModuleName + "-" + HashStr.str() + ".pcm");
144 return Result.str().str();
147 Module *HeaderSearch::lookupModule(StringRef ModuleName, bool AllowSearch) {
148 // Look in the module map to determine if there is a module by this name.
149 Module *Module = ModMap.findModule(ModuleName);
150 if (Module || !AllowSearch)
153 // Look through the various header search paths to load any available module
154 // maps, searching for a module map that describes this module.
155 for (unsigned Idx = 0, N = SearchDirs.size(); Idx != N; ++Idx) {
156 if (SearchDirs[Idx].isFramework()) {
157 // Search for or infer a module map for a framework.
158 SmallString<128> FrameworkDirName;
159 FrameworkDirName += SearchDirs[Idx].getFrameworkDir()->getName();
160 llvm::sys::path::append(FrameworkDirName, ModuleName + ".framework");
161 if (const DirectoryEntry *FrameworkDir
162 = FileMgr.getDirectory(FrameworkDirName)) {
164 = SearchDirs[Idx].getDirCharacteristic() != SrcMgr::C_User;
165 Module = loadFrameworkModule(ModuleName, FrameworkDir, IsSystem);
171 // FIXME: Figure out how header maps and module maps will work together.
173 // Only deal with normal search directories.
174 if (!SearchDirs[Idx].isNormalDir())
177 bool IsSystem = SearchDirs[Idx].isSystemHeaderDirectory();
178 // Search for a module map file in this directory.
179 if (loadModuleMapFile(SearchDirs[Idx].getDir(), IsSystem,
180 /*IsFramework*/false) == LMM_NewlyLoaded) {
181 // We just loaded a module map file; check whether the module is
183 Module = ModMap.findModule(ModuleName);
188 // Search for a module map in a subdirectory with the same name as the
190 SmallString<128> NestedModuleMapDirName;
191 NestedModuleMapDirName = SearchDirs[Idx].getDir()->getName();
192 llvm::sys::path::append(NestedModuleMapDirName, ModuleName);
193 if (loadModuleMapFile(NestedModuleMapDirName, IsSystem,
194 /*IsFramework*/false) == LMM_NewlyLoaded){
195 // If we just loaded a module map file, look for the module again.
196 Module = ModMap.findModule(ModuleName);
201 // If we've already performed the exhaustive search for module maps in this
202 // search directory, don't do it again.
203 if (SearchDirs[Idx].haveSearchedAllModuleMaps())
206 // Load all module maps in the immediate subdirectories of this search
208 loadSubdirectoryModuleMaps(SearchDirs[Idx]);
210 // Look again for the module.
211 Module = ModMap.findModule(ModuleName);
219 //===----------------------------------------------------------------------===//
220 // File lookup within a DirectoryLookup scope
221 //===----------------------------------------------------------------------===//
223 /// getName - Return the directory or filename corresponding to this lookup
225 const char *DirectoryLookup::getName() const {
227 return getDir()->getName();
229 return getFrameworkDir()->getName();
230 assert(isHeaderMap() && "Unknown DirectoryLookup");
231 return getHeaderMap()->getFileName();
234 static const FileEntry *
235 getFileAndSuggestModule(HeaderSearch &HS, StringRef FileName,
236 const DirectoryEntry *Dir, bool IsSystemHeaderDir,
237 ModuleMap::KnownHeader *SuggestedModule) {
238 // If we have a module map that might map this header, load it and
239 // check whether we'll have a suggestion for a module.
240 HS.hasModuleMap(FileName, Dir, IsSystemHeaderDir);
241 if (SuggestedModule) {
242 const FileEntry *File = HS.getFileMgr().getFile(FileName,
245 // If there is a module that corresponds to this header, suggest it.
246 *SuggestedModule = HS.findModuleForHeader(File);
248 // FIXME: This appears to be a no-op. We loaded the module map for this
249 // directory at the start of this function.
250 if (!SuggestedModule->getModule() &&
251 HS.hasModuleMap(FileName, Dir, IsSystemHeaderDir))
252 *SuggestedModule = HS.findModuleForHeader(File);
258 return HS.getFileMgr().getFile(FileName, /*openFile=*/true);
261 /// LookupFile - Lookup the specified file in this search path, returning it
262 /// if it exists or returning null if not.
263 const FileEntry *DirectoryLookup::LookupFile(
266 SmallVectorImpl<char> *SearchPath,
267 SmallVectorImpl<char> *RelativePath,
268 ModuleMap::KnownHeader *SuggestedModule,
269 bool &InUserSpecifiedSystemFramework,
271 SmallVectorImpl<char> &MappedName) const {
272 InUserSpecifiedSystemFramework = false;
273 HasBeenMapped = false;
275 SmallString<1024> TmpDir;
277 // Concatenate the requested file onto the directory.
278 TmpDir = getDir()->getName();
279 llvm::sys::path::append(TmpDir, Filename);
281 StringRef SearchPathRef(getDir()->getName());
283 SearchPath->append(SearchPathRef.begin(), SearchPathRef.end());
286 RelativePath->clear();
287 RelativePath->append(Filename.begin(), Filename.end());
290 return getFileAndSuggestModule(HS, TmpDir.str(), getDir(),
291 isSystemHeaderDirectory(),
296 return DoFrameworkLookup(Filename, HS, SearchPath, RelativePath,
297 SuggestedModule, InUserSpecifiedSystemFramework);
299 assert(isHeaderMap() && "Unknown directory lookup");
300 const HeaderMap *HM = getHeaderMap();
301 SmallString<1024> Path;
302 StringRef Dest = HM->lookupFilename(Filename, Path);
306 const FileEntry *Result;
308 // Check if the headermap maps the filename to a framework include
309 // ("Foo.h" -> "Foo/Foo.h"), in which case continue header lookup using the
310 // framework include.
311 if (llvm::sys::path::is_relative(Dest)) {
313 MappedName.append(Dest.begin(), Dest.end());
314 Filename = StringRef(MappedName.begin(), MappedName.size());
315 HasBeenMapped = true;
316 Result = HM->LookupFile(Filename, HS.getFileMgr());
319 Result = HS.getFileMgr().getFile(Dest);
324 StringRef SearchPathRef(getName());
326 SearchPath->append(SearchPathRef.begin(), SearchPathRef.end());
329 RelativePath->clear();
330 RelativePath->append(Filename.begin(), Filename.end());
336 /// \brief Given a framework directory, find the top-most framework directory.
338 /// \param FileMgr The file manager to use for directory lookups.
339 /// \param DirName The name of the framework directory.
340 /// \param SubmodulePath Will be populated with the submodule path from the
341 /// returned top-level module to the originally named framework.
342 static const DirectoryEntry *
343 getTopFrameworkDir(FileManager &FileMgr, StringRef DirName,
344 SmallVectorImpl<std::string> &SubmodulePath) {
345 assert(llvm::sys::path::extension(DirName) == ".framework" &&
346 "Not a framework directory");
348 // Note: as an egregious but useful hack we use the real path here, because
349 // frameworks moving between top-level frameworks to embedded frameworks tend
350 // to be symlinked, and we base the logical structure of modules on the
351 // physical layout. In particular, we need to deal with crazy includes like
353 // #include <Foo/Frameworks/Bar.framework/Headers/Wibble.h>
355 // where 'Bar' used to be embedded in 'Foo', is now a top-level framework
356 // which one should access with, e.g.,
358 // #include <Bar/Wibble.h>
360 // Similar issues occur when a top-level framework has moved into an
361 // embedded framework.
362 const DirectoryEntry *TopFrameworkDir = FileMgr.getDirectory(DirName);
363 DirName = FileMgr.getCanonicalName(TopFrameworkDir);
365 // Get the parent directory name.
366 DirName = llvm::sys::path::parent_path(DirName);
370 // Determine whether this directory exists.
371 const DirectoryEntry *Dir = FileMgr.getDirectory(DirName);
375 // If this is a framework directory, then we're a subframework of this
377 if (llvm::sys::path::extension(DirName) == ".framework") {
378 SubmodulePath.push_back(llvm::sys::path::stem(DirName));
379 TopFrameworkDir = Dir;
383 return TopFrameworkDir;
386 /// DoFrameworkLookup - Do a lookup of the specified file in the current
387 /// DirectoryLookup, which is a framework directory.
388 const FileEntry *DirectoryLookup::DoFrameworkLookup(
391 SmallVectorImpl<char> *SearchPath,
392 SmallVectorImpl<char> *RelativePath,
393 ModuleMap::KnownHeader *SuggestedModule,
394 bool &InUserSpecifiedSystemFramework) const
396 FileManager &FileMgr = HS.getFileMgr();
398 // Framework names must have a '/' in the filename.
399 size_t SlashPos = Filename.find('/');
400 if (SlashPos == StringRef::npos) return nullptr;
402 // Find out if this is the home for the specified framework, by checking
403 // HeaderSearch. Possible answers are yes/no and unknown.
404 HeaderSearch::FrameworkCacheEntry &CacheEntry =
405 HS.LookupFrameworkCache(Filename.substr(0, SlashPos));
407 // If it is known and in some other directory, fail.
408 if (CacheEntry.Directory && CacheEntry.Directory != getFrameworkDir())
411 // Otherwise, construct the path to this framework dir.
413 // FrameworkName = "/System/Library/Frameworks/"
414 SmallString<1024> FrameworkName;
415 FrameworkName += getFrameworkDir()->getName();
416 if (FrameworkName.empty() || FrameworkName.back() != '/')
417 FrameworkName.push_back('/');
419 // FrameworkName = "/System/Library/Frameworks/Cocoa"
420 StringRef ModuleName(Filename.begin(), SlashPos);
421 FrameworkName += ModuleName;
423 // FrameworkName = "/System/Library/Frameworks/Cocoa.framework/"
424 FrameworkName += ".framework/";
426 // If the cache entry was unresolved, populate it now.
427 if (!CacheEntry.Directory) {
428 HS.IncrementFrameworkLookupCount();
430 // If the framework dir doesn't exist, we fail.
431 const DirectoryEntry *Dir = FileMgr.getDirectory(FrameworkName.str());
432 if (!Dir) return nullptr;
434 // Otherwise, if it does, remember that this is the right direntry for this
436 CacheEntry.Directory = getFrameworkDir();
438 // If this is a user search directory, check if the framework has been
439 // user-specified as a system framework.
440 if (getDirCharacteristic() == SrcMgr::C_User) {
441 SmallString<1024> SystemFrameworkMarker(FrameworkName);
442 SystemFrameworkMarker += ".system_framework";
443 if (llvm::sys::fs::exists(SystemFrameworkMarker.str())) {
444 CacheEntry.IsUserSpecifiedSystemFramework = true;
449 // Set the 'user-specified system framework' flag.
450 InUserSpecifiedSystemFramework = CacheEntry.IsUserSpecifiedSystemFramework;
453 RelativePath->clear();
454 RelativePath->append(Filename.begin()+SlashPos+1, Filename.end());
457 // Check "/System/Library/Frameworks/Cocoa.framework/Headers/file.h"
458 unsigned OrigSize = FrameworkName.size();
460 FrameworkName += "Headers/";
464 // Without trailing '/'.
465 SearchPath->append(FrameworkName.begin(), FrameworkName.end()-1);
468 FrameworkName.append(Filename.begin()+SlashPos+1, Filename.end());
469 const FileEntry *FE = FileMgr.getFile(FrameworkName.str(),
470 /*openFile=*/!SuggestedModule);
472 // Check "/System/Library/Frameworks/Cocoa.framework/PrivateHeaders/file.h"
473 const char *Private = "Private";
474 FrameworkName.insert(FrameworkName.begin()+OrigSize, Private,
475 Private+strlen(Private));
477 SearchPath->insert(SearchPath->begin()+OrigSize, Private,
478 Private+strlen(Private));
480 FE = FileMgr.getFile(FrameworkName.str(), /*openFile=*/!SuggestedModule);
483 // If we found the header and are allowed to suggest a module, do so now.
484 if (FE && SuggestedModule) {
485 // Find the framework in which this header occurs.
486 StringRef FrameworkPath = FE->getDir()->getName();
487 bool FoundFramework = false;
489 // Determine whether this directory exists.
490 const DirectoryEntry *Dir = FileMgr.getDirectory(FrameworkPath);
494 // If this is a framework directory, then we're a subframework of this
496 if (llvm::sys::path::extension(FrameworkPath) == ".framework") {
497 FoundFramework = true;
501 // Get the parent directory name.
502 FrameworkPath = llvm::sys::path::parent_path(FrameworkPath);
503 if (FrameworkPath.empty())
507 if (FoundFramework) {
508 // Find the top-level framework based on this framework.
509 SmallVector<std::string, 4> SubmodulePath;
510 const DirectoryEntry *TopFrameworkDir
511 = ::getTopFrameworkDir(FileMgr, FrameworkPath, SubmodulePath);
513 // Determine the name of the top-level framework.
514 StringRef ModuleName = llvm::sys::path::stem(TopFrameworkDir->getName());
516 // Load this framework module. If that succeeds, find the suggested module
517 // for this header, if any.
518 bool IsSystem = getDirCharacteristic() != SrcMgr::C_User;
519 if (HS.loadFrameworkModule(ModuleName, TopFrameworkDir, IsSystem)) {
520 *SuggestedModule = HS.findModuleForHeader(FE);
523 *SuggestedModule = HS.findModuleForHeader(FE);
529 void HeaderSearch::setTarget(const TargetInfo &Target) {
530 ModMap.setTarget(Target);
534 //===----------------------------------------------------------------------===//
535 // Header File Location.
536 //===----------------------------------------------------------------------===//
538 /// \brief Return true with a diagnostic if the file that MSVC would have found
539 /// fails to match the one that Clang would have found with MSVC header search
541 static bool checkMSVCHeaderSearch(DiagnosticsEngine &Diags,
542 const FileEntry *MSFE, const FileEntry *FE,
543 SourceLocation IncludeLoc) {
544 if (MSFE && FE != MSFE) {
545 Diags.Report(IncludeLoc, diag::ext_pp_include_search_ms) << MSFE->getName();
551 static const char *copyString(StringRef Str, llvm::BumpPtrAllocator &Alloc) {
552 assert(!Str.empty());
553 char *CopyStr = Alloc.Allocate<char>(Str.size()+1);
554 std::copy(Str.begin(), Str.end(), CopyStr);
555 CopyStr[Str.size()] = '\0';
559 /// LookupFile - Given a "foo" or \<foo> reference, look up the indicated file,
560 /// return null on failure. isAngled indicates whether the file reference is
561 /// for system \#include's or not (i.e. using <> instead of ""). Includers, if
562 /// non-empty, indicates where the \#including file(s) are, in case a relative
563 /// search is needed. Microsoft mode will pass all \#including files.
564 const FileEntry *HeaderSearch::LookupFile(
565 StringRef Filename, SourceLocation IncludeLoc, bool isAngled,
566 const DirectoryLookup *FromDir, const DirectoryLookup *&CurDir,
567 ArrayRef<const FileEntry *> Includers, SmallVectorImpl<char> *SearchPath,
568 SmallVectorImpl<char> *RelativePath,
569 ModuleMap::KnownHeader *SuggestedModule, bool SkipCache) {
570 if (!HSOpts->ModuleMapFiles.empty()) {
571 // Preload all explicitly specified module map files. This enables modules
572 // map files lying in a directory structure separate from the header files
573 // that they describe. These cannot be loaded lazily upon encountering a
574 // header file, as there is no other known mapping from a header file to its
576 for (llvm::SetVector<std::string>::iterator
577 I = HSOpts->ModuleMapFiles.begin(),
578 E = HSOpts->ModuleMapFiles.end();
580 const FileEntry *File = FileMgr.getFile(*I);
583 loadModuleMapFile(File, /*IsSystem=*/false);
585 HSOpts->ModuleMapFiles.clear();
589 *SuggestedModule = ModuleMap::KnownHeader();
591 // If 'Filename' is absolute, check to see if it exists and no searching.
592 if (llvm::sys::path::is_absolute(Filename)) {
595 // If this was an #include_next "/absolute/file", fail.
596 if (FromDir) return nullptr;
601 RelativePath->clear();
602 RelativePath->append(Filename.begin(), Filename.end());
604 // Otherwise, just return the file.
605 return FileMgr.getFile(Filename, /*openFile=*/true);
608 // This is the header that MSVC's header search would have found.
609 const FileEntry *MSFE = nullptr;
610 ModuleMap::KnownHeader MSSuggestedModule;
612 // Unless disabled, check to see if the file is in the #includer's
613 // directory. This cannot be based on CurDir, because each includer could be
614 // a #include of a subdirectory (#include "foo/bar.h") and a subsequent
615 // include of "baz.h" should resolve to "whatever/foo/baz.h".
616 // This search is not done for <> headers.
617 if (!Includers.empty() && !isAngled && !NoCurDirSearch) {
618 SmallString<1024> TmpDir;
619 for (ArrayRef<const FileEntry *>::iterator I = Includers.begin(),
622 const FileEntry *Includer = *I;
623 // Concatenate the requested file onto the directory.
624 // FIXME: Portability. Filename concatenation should be in sys::Path.
625 TmpDir = Includer->getDir()->getName();
626 TmpDir.push_back('/');
627 TmpDir.append(Filename.begin(), Filename.end());
629 // FIXME: We don't cache the result of getFileInfo across the call to
630 // getFileAndSuggestModule, because it's a reference to an element of
631 // a container that could be reallocated across this call.
632 bool IncluderIsSystemHeader =
633 getFileInfo(Includer).DirInfo != SrcMgr::C_User;
634 if (const FileEntry *FE =
635 getFileAndSuggestModule(*this, TmpDir.str(), Includer->getDir(),
636 IncluderIsSystemHeader,
638 // Leave CurDir unset.
639 // This file is a system header or C++ unfriendly if the old file is.
641 // Note that we only use one of FromHFI/ToHFI at once, due to potential
642 // reallocation of the underlying vector potentially making the first
643 // reference binding dangling.
644 HeaderFileInfo &FromHFI = getFileInfo(Includer);
645 unsigned DirInfo = FromHFI.DirInfo;
646 bool IndexHeaderMapHeader = FromHFI.IndexHeaderMapHeader;
647 StringRef Framework = FromHFI.Framework;
649 HeaderFileInfo &ToHFI = getFileInfo(FE);
650 ToHFI.DirInfo = DirInfo;
651 ToHFI.IndexHeaderMapHeader = IndexHeaderMapHeader;
652 ToHFI.Framework = Framework;
655 StringRef SearchPathRef(Includer->getDir()->getName());
657 SearchPath->append(SearchPathRef.begin(), SearchPathRef.end());
660 RelativePath->clear();
661 RelativePath->append(Filename.begin(), Filename.end());
663 if (I == Includers.begin())
666 // Otherwise, we found the path via MSVC header search rules. If
667 // -Wmsvc-include is enabled, we have to keep searching to see if we
668 // would've found this header in -I or -isystem directories.
669 if (Diags.isIgnored(diag::ext_pp_include_search_ms, IncludeLoc)) {
673 if (SuggestedModule) {
674 MSSuggestedModule = *SuggestedModule;
675 *SuggestedModule = ModuleMap::KnownHeader();
685 // If this is a system #include, ignore the user #include locs.
686 unsigned i = isAngled ? AngledDirIdx : 0;
688 // If this is a #include_next request, start searching after the directory the
689 // file was found in.
691 i = FromDir-&SearchDirs[0];
693 // Cache all of the lookups performed by this method. Many headers are
694 // multiply included, and the "pragma once" optimization prevents them from
695 // being relex/pp'd, but they would still have to search through a
696 // (potentially huge) series of SearchDirs to find it.
697 LookupFileCacheInfo &CacheLookup =
698 LookupFileCache.GetOrCreateValue(Filename).getValue();
700 // If the entry has been previously looked up, the first value will be
701 // non-zero. If the value is equal to i (the start point of our search), then
702 // this is a matching hit.
703 if (!SkipCache && CacheLookup.StartIdx == i+1) {
704 // Skip querying potentially lots of directories for this lookup.
705 i = CacheLookup.HitIdx;
706 if (CacheLookup.MappedName)
707 Filename = CacheLookup.MappedName;
709 // Otherwise, this is the first query, or the previous query didn't match
710 // our search start. We will fill in our found location below, so prime the
711 // start point value.
712 CacheLookup.reset(/*StartIdx=*/i+1);
715 SmallString<64> MappedName;
717 // Check each directory in sequence to see if it contains this file.
718 for (; i != SearchDirs.size(); ++i) {
719 bool InUserSpecifiedSystemFramework = false;
720 bool HasBeenMapped = false;
721 const FileEntry *FE =
722 SearchDirs[i].LookupFile(Filename, *this, SearchPath, RelativePath,
723 SuggestedModule, InUserSpecifiedSystemFramework,
724 HasBeenMapped, MappedName);
726 CacheLookup.MappedName =
727 copyString(Filename, LookupFileCache.getAllocator());
731 CurDir = &SearchDirs[i];
733 // This file is a system header or C++ unfriendly if the dir is.
734 HeaderFileInfo &HFI = getFileInfo(FE);
735 HFI.DirInfo = CurDir->getDirCharacteristic();
737 // If the directory characteristic is User but this framework was
738 // user-specified to be treated as a system framework, promote the
740 if (HFI.DirInfo == SrcMgr::C_User && InUserSpecifiedSystemFramework)
741 HFI.DirInfo = SrcMgr::C_System;
743 // If the filename matches a known system header prefix, override
744 // whether the file is a system header.
745 for (unsigned j = SystemHeaderPrefixes.size(); j; --j) {
746 if (Filename.startswith(SystemHeaderPrefixes[j-1].first)) {
747 HFI.DirInfo = SystemHeaderPrefixes[j-1].second ? SrcMgr::C_System
753 // If this file is found in a header map and uses the framework style of
754 // includes, then this header is part of a framework we're building.
755 if (CurDir->isIndexHeaderMap()) {
756 size_t SlashPos = Filename.find('/');
757 if (SlashPos != StringRef::npos) {
758 HFI.IndexHeaderMapHeader = 1;
759 HFI.Framework = getUniqueFrameworkName(StringRef(Filename.begin(),
764 if (checkMSVCHeaderSearch(Diags, MSFE, FE, IncludeLoc)) {
766 *SuggestedModule = MSSuggestedModule;
770 // Remember this location for the next lookup we do.
771 CacheLookup.HitIdx = i;
775 // If we are including a file with a quoted include "foo.h" from inside
776 // a header in a framework that is currently being built, and we couldn't
777 // resolve "foo.h" any other way, change the include to <Foo/foo.h>, where
778 // "Foo" is the name of the framework in which the including header was found.
779 if (!Includers.empty() && !isAngled &&
780 Filename.find('/') == StringRef::npos) {
781 HeaderFileInfo &IncludingHFI = getFileInfo(Includers.front());
782 if (IncludingHFI.IndexHeaderMapHeader) {
783 SmallString<128> ScratchFilename;
784 ScratchFilename += IncludingHFI.Framework;
785 ScratchFilename += '/';
786 ScratchFilename += Filename;
788 const FileEntry *FE = LookupFile(
789 ScratchFilename, IncludeLoc, /*isAngled=*/true, FromDir, CurDir,
790 Includers.front(), SearchPath, RelativePath, SuggestedModule);
792 if (checkMSVCHeaderSearch(Diags, MSFE, FE, IncludeLoc)) {
794 *SuggestedModule = MSSuggestedModule;
798 LookupFileCacheInfo &CacheLookup
799 = LookupFileCache.GetOrCreateValue(Filename).getValue();
801 = LookupFileCache.GetOrCreateValue(ScratchFilename).getValue().HitIdx;
802 // FIXME: SuggestedModule.
807 if (checkMSVCHeaderSearch(Diags, MSFE, nullptr, IncludeLoc)) {
809 *SuggestedModule = MSSuggestedModule;
813 // Otherwise, didn't find it. Remember we didn't find this.
814 CacheLookup.HitIdx = SearchDirs.size();
818 /// LookupSubframeworkHeader - Look up a subframework for the specified
819 /// \#include file. For example, if \#include'ing <HIToolbox/HIToolbox.h> from
820 /// within ".../Carbon.framework/Headers/Carbon.h", check to see if HIToolbox
821 /// is a subframework within Carbon.framework. If so, return the FileEntry
822 /// for the designated file, otherwise return null.
823 const FileEntry *HeaderSearch::
824 LookupSubframeworkHeader(StringRef Filename,
825 const FileEntry *ContextFileEnt,
826 SmallVectorImpl<char> *SearchPath,
827 SmallVectorImpl<char> *RelativePath,
828 ModuleMap::KnownHeader *SuggestedModule) {
829 assert(ContextFileEnt && "No context file?");
831 // Framework names must have a '/' in the filename. Find it.
832 // FIXME: Should we permit '\' on Windows?
833 size_t SlashPos = Filename.find('/');
834 if (SlashPos == StringRef::npos) return nullptr;
836 // Look up the base framework name of the ContextFileEnt.
837 const char *ContextName = ContextFileEnt->getName();
839 // If the context info wasn't a framework, couldn't be a subframework.
840 const unsigned DotFrameworkLen = 10;
841 const char *FrameworkPos = strstr(ContextName, ".framework");
842 if (FrameworkPos == nullptr ||
843 (FrameworkPos[DotFrameworkLen] != '/' &&
844 FrameworkPos[DotFrameworkLen] != '\\'))
847 SmallString<1024> FrameworkName(ContextName, FrameworkPos+DotFrameworkLen+1);
849 // Append Frameworks/HIToolbox.framework/
850 FrameworkName += "Frameworks/";
851 FrameworkName.append(Filename.begin(), Filename.begin()+SlashPos);
852 FrameworkName += ".framework/";
854 llvm::StringMapEntry<FrameworkCacheEntry> &CacheLookup =
855 FrameworkMap.GetOrCreateValue(Filename.substr(0, SlashPos));
857 // Some other location?
858 if (CacheLookup.getValue().Directory &&
859 CacheLookup.getKeyLength() == FrameworkName.size() &&
860 memcmp(CacheLookup.getKeyData(), &FrameworkName[0],
861 CacheLookup.getKeyLength()) != 0)
864 // Cache subframework.
865 if (!CacheLookup.getValue().Directory) {
866 ++NumSubFrameworkLookups;
868 // If the framework dir doesn't exist, we fail.
869 const DirectoryEntry *Dir = FileMgr.getDirectory(FrameworkName.str());
870 if (!Dir) return nullptr;
872 // Otherwise, if it does, remember that this is the right direntry for this
874 CacheLookup.getValue().Directory = Dir;
877 const FileEntry *FE = nullptr;
880 RelativePath->clear();
881 RelativePath->append(Filename.begin()+SlashPos+1, Filename.end());
884 // Check ".../Frameworks/HIToolbox.framework/Headers/HIToolbox.h"
885 SmallString<1024> HeadersFilename(FrameworkName);
886 HeadersFilename += "Headers/";
889 // Without trailing '/'.
890 SearchPath->append(HeadersFilename.begin(), HeadersFilename.end()-1);
893 HeadersFilename.append(Filename.begin()+SlashPos+1, Filename.end());
894 if (!(FE = FileMgr.getFile(HeadersFilename.str(), /*openFile=*/true))) {
896 // Check ".../Frameworks/HIToolbox.framework/PrivateHeaders/HIToolbox.h"
897 HeadersFilename = FrameworkName;
898 HeadersFilename += "PrivateHeaders/";
901 // Without trailing '/'.
902 SearchPath->append(HeadersFilename.begin(), HeadersFilename.end()-1);
905 HeadersFilename.append(Filename.begin()+SlashPos+1, Filename.end());
906 if (!(FE = FileMgr.getFile(HeadersFilename.str(), /*openFile=*/true)))
910 // This file is a system header or C++ unfriendly if the old file is.
912 // Note that the temporary 'DirInfo' is required here, as either call to
913 // getFileInfo could resize the vector and we don't want to rely on order
915 unsigned DirInfo = getFileInfo(ContextFileEnt).DirInfo;
916 getFileInfo(FE).DirInfo = DirInfo;
918 // If we're supposed to suggest a module, look for one now.
919 if (SuggestedModule) {
920 // Find the top-level framework based on this framework.
921 FrameworkName.pop_back(); // remove the trailing '/'
922 SmallVector<std::string, 4> SubmodulePath;
923 const DirectoryEntry *TopFrameworkDir
924 = ::getTopFrameworkDir(FileMgr, FrameworkName, SubmodulePath);
926 // Determine the name of the top-level framework.
927 StringRef ModuleName = llvm::sys::path::stem(TopFrameworkDir->getName());
929 // Load this framework module. If that succeeds, find the suggested module
930 // for this header, if any.
931 bool IsSystem = false;
932 if (loadFrameworkModule(ModuleName, TopFrameworkDir, IsSystem)) {
933 *SuggestedModule = findModuleForHeader(FE);
940 /// \brief Helper static function to normalize a path for injection into
941 /// a synthetic header.
942 /*static*/ std::string
943 HeaderSearch::NormalizeDashIncludePath(StringRef File, FileManager &FileMgr) {
944 // Implicit include paths should be resolved relative to the current
945 // working directory first, and then use the regular header search
946 // mechanism. The proper way to handle this is to have the
947 // predefines buffer located at the current working directory, but
948 // it has no file entry. For now, workaround this by using an
949 // absolute path if we find the file here, and otherwise letting
950 // header search handle it.
951 SmallString<128> Path(File);
952 llvm::sys::fs::make_absolute(Path);
954 if (llvm::sys::fs::exists(Path.str(), exists) || !exists)
957 FileMgr.getFile(File);
959 return Lexer::Stringify(Path.str());
962 //===----------------------------------------------------------------------===//
963 // File Info Management.
964 //===----------------------------------------------------------------------===//
966 /// \brief Merge the header file info provided by \p OtherHFI into the current
967 /// header file info (\p HFI)
968 static void mergeHeaderFileInfo(HeaderFileInfo &HFI,
969 const HeaderFileInfo &OtherHFI) {
970 HFI.isImport |= OtherHFI.isImport;
971 HFI.isPragmaOnce |= OtherHFI.isPragmaOnce;
972 HFI.isModuleHeader |= OtherHFI.isModuleHeader;
973 HFI.NumIncludes += OtherHFI.NumIncludes;
975 if (!HFI.ControllingMacro && !HFI.ControllingMacroID) {
976 HFI.ControllingMacro = OtherHFI.ControllingMacro;
977 HFI.ControllingMacroID = OtherHFI.ControllingMacroID;
980 if (OtherHFI.External) {
981 HFI.DirInfo = OtherHFI.DirInfo;
982 HFI.External = OtherHFI.External;
983 HFI.IndexHeaderMapHeader = OtherHFI.IndexHeaderMapHeader;
986 if (HFI.Framework.empty())
987 HFI.Framework = OtherHFI.Framework;
992 /// getFileInfo - Return the HeaderFileInfo structure for the specified
994 HeaderFileInfo &HeaderSearch::getFileInfo(const FileEntry *FE) {
995 if (FE->getUID() >= FileInfo.size())
996 FileInfo.resize(FE->getUID()+1);
998 HeaderFileInfo &HFI = FileInfo[FE->getUID()];
999 if (ExternalSource && !HFI.Resolved)
1000 mergeHeaderFileInfo(HFI, ExternalSource->GetHeaderFileInfo(FE));
1005 bool HeaderSearch::tryGetFileInfo(const FileEntry *FE, HeaderFileInfo &Result) const {
1006 if (FE->getUID() >= FileInfo.size())
1008 const HeaderFileInfo &HFI = FileInfo[FE->getUID()];
1016 bool HeaderSearch::isFileMultipleIncludeGuarded(const FileEntry *File) {
1017 // Check if we've ever seen this file as a header.
1018 if (File->getUID() >= FileInfo.size())
1021 // Resolve header file info from the external source, if needed.
1022 HeaderFileInfo &HFI = FileInfo[File->getUID()];
1023 if (ExternalSource && !HFI.Resolved)
1024 mergeHeaderFileInfo(HFI, ExternalSource->GetHeaderFileInfo(File));
1026 return HFI.isPragmaOnce || HFI.isImport ||
1027 HFI.ControllingMacro || HFI.ControllingMacroID;
1030 void HeaderSearch::MarkFileModuleHeader(const FileEntry *FE,
1031 ModuleMap::ModuleHeaderRole Role,
1032 bool isCompilingModuleHeader) {
1033 if (FE->getUID() >= FileInfo.size())
1034 FileInfo.resize(FE->getUID()+1);
1036 HeaderFileInfo &HFI = FileInfo[FE->getUID()];
1037 HFI.isModuleHeader = true;
1038 HFI.isCompilingModuleHeader = isCompilingModuleHeader;
1039 HFI.setHeaderRole(Role);
1042 bool HeaderSearch::ShouldEnterIncludeFile(const FileEntry *File, bool isImport){
1043 ++NumIncluded; // Count # of attempted #includes.
1045 // Get information about this file.
1046 HeaderFileInfo &FileInfo = getFileInfo(File);
1048 // If this is a #import directive, check that we have not already imported
1051 // If this has already been imported, don't import it again.
1052 FileInfo.isImport = true;
1054 // Has this already been #import'ed or #include'd?
1055 if (FileInfo.NumIncludes) return false;
1057 // Otherwise, if this is a #include of a file that was previously #import'd
1058 // or if this is the second #include of a #pragma once file, ignore it.
1059 if (FileInfo.isImport)
1063 // Next, check to see if the file is wrapped with #ifndef guards. If so, and
1064 // if the macro that guards it is defined, we know the #include has no effect.
1065 if (const IdentifierInfo *ControllingMacro
1066 = FileInfo.getControllingMacro(ExternalLookup))
1067 if (ControllingMacro->hasMacroDefinition()) {
1068 ++NumMultiIncludeFileOptzn;
1072 // Increment the number of times this file has been included.
1073 ++FileInfo.NumIncludes;
1078 size_t HeaderSearch::getTotalMemory() const {
1079 return SearchDirs.capacity()
1080 + llvm::capacity_in_bytes(FileInfo)
1081 + llvm::capacity_in_bytes(HeaderMaps)
1082 + LookupFileCache.getAllocator().getTotalMemory()
1083 + FrameworkMap.getAllocator().getTotalMemory();
1086 StringRef HeaderSearch::getUniqueFrameworkName(StringRef Framework) {
1087 return FrameworkNames.GetOrCreateValue(Framework).getKey();
1090 bool HeaderSearch::hasModuleMap(StringRef FileName,
1091 const DirectoryEntry *Root,
1093 if (!enabledModules())
1096 SmallVector<const DirectoryEntry *, 2> FixUpDirectories;
1098 StringRef DirName = FileName;
1100 // Get the parent directory name.
1101 DirName = llvm::sys::path::parent_path(DirName);
1102 if (DirName.empty())
1105 // Determine whether this directory exists.
1106 const DirectoryEntry *Dir = FileMgr.getDirectory(DirName);
1110 // Try to load the module map file in this directory.
1111 switch (loadModuleMapFile(Dir, IsSystem, /*IsFramework*/false)) {
1112 case LMM_NewlyLoaded:
1113 case LMM_AlreadyLoaded:
1114 // Success. All of the directories we stepped through inherit this module
1116 for (unsigned I = 0, N = FixUpDirectories.size(); I != N; ++I)
1117 DirectoryHasModuleMap[FixUpDirectories[I]] = true;
1120 case LMM_NoDirectory:
1121 case LMM_InvalidModuleMap:
1125 // If we hit the top of our search, we're done.
1129 // Keep track of all of the directories we checked, so we can mark them as
1130 // having module maps if we eventually do find a module map.
1131 FixUpDirectories.push_back(Dir);
1135 ModuleMap::KnownHeader
1136 HeaderSearch::findModuleForHeader(const FileEntry *File) const {
1137 if (ExternalSource) {
1138 // Make sure the external source has handled header info about this file,
1139 // which includes whether the file is part of a module.
1140 (void)getFileInfo(File);
1142 return ModMap.findModuleForHeader(File);
1145 static const FileEntry *getPrivateModuleMap(StringRef ModuleMapPath,
1146 const DirectoryEntry *Directory,
1147 FileManager &FileMgr) {
1148 StringRef Filename = llvm::sys::path::filename(ModuleMapPath);
1149 SmallString<128> PrivateFilename(Directory->getName());
1150 if (Filename == "module.map")
1151 llvm::sys::path::append(PrivateFilename, "module_private.map");
1152 else if (Filename == "module.modulemap")
1153 llvm::sys::path::append(PrivateFilename, "module.private.modulemap");
1156 return FileMgr.getFile(PrivateFilename);
1159 bool HeaderSearch::loadModuleMapFile(const FileEntry *File, bool IsSystem) {
1160 switch (loadModuleMapFileImpl(File, IsSystem)) {
1161 case LMM_AlreadyLoaded:
1162 case LMM_NewlyLoaded:
1164 case LMM_NoDirectory:
1165 case LMM_InvalidModuleMap:
1168 llvm_unreachable("Unknown load module map result");
1171 HeaderSearch::LoadModuleMapResult
1172 HeaderSearch::loadModuleMapFileImpl(const FileEntry *File, bool IsSystem) {
1173 assert(File && "expected FileEntry");
1175 const DirectoryEntry *Dir = File->getDir();
1176 auto KnownDir = DirectoryHasModuleMap.find(Dir);
1177 if (KnownDir != DirectoryHasModuleMap.end())
1178 return KnownDir->second ? LMM_AlreadyLoaded : LMM_InvalidModuleMap;
1180 if (ModMap.parseModuleMapFile(File, IsSystem)) {
1181 DirectoryHasModuleMap[Dir] = false;
1182 return LMM_InvalidModuleMap;
1185 // Try to load a corresponding private module map.
1186 if (const FileEntry *PMMFile =
1187 getPrivateModuleMap(File->getName(), Dir, FileMgr)) {
1188 if (ModMap.parseModuleMapFile(PMMFile, IsSystem)) {
1189 DirectoryHasModuleMap[Dir] = false;
1190 return LMM_InvalidModuleMap;
1194 // This directory has a module map.
1195 DirectoryHasModuleMap[Dir] = true;
1196 return LMM_NewlyLoaded;
1200 HeaderSearch::lookupModuleMapFile(const DirectoryEntry *Dir, bool IsFramework) {
1201 // For frameworks, the preferred spelling is Modules/module.modulemap, but
1202 // module.map at the framework root is also accepted.
1203 SmallString<128> ModuleMapFileName(Dir->getName());
1205 llvm::sys::path::append(ModuleMapFileName, "Modules");
1206 llvm::sys::path::append(ModuleMapFileName, "module.modulemap");
1207 if (const FileEntry *F = FileMgr.getFile(ModuleMapFileName))
1210 // Continue to allow module.map
1211 ModuleMapFileName = Dir->getName();
1212 llvm::sys::path::append(ModuleMapFileName, "module.map");
1213 return FileMgr.getFile(ModuleMapFileName);
1216 Module *HeaderSearch::loadFrameworkModule(StringRef Name,
1217 const DirectoryEntry *Dir,
1219 if (Module *Module = ModMap.findModule(Name))
1222 // Try to load a module map file.
1223 switch (loadModuleMapFile(Dir, IsSystem, /*IsFramework*/true)) {
1224 case LMM_InvalidModuleMap:
1227 case LMM_AlreadyLoaded:
1228 case LMM_NoDirectory:
1231 case LMM_NewlyLoaded:
1232 return ModMap.findModule(Name);
1236 // Try to infer a module map from the framework directory.
1237 return ModMap.inferFrameworkModule(Name, Dir, IsSystem, /*Parent=*/nullptr);
1241 HeaderSearch::LoadModuleMapResult
1242 HeaderSearch::loadModuleMapFile(StringRef DirName, bool IsSystem,
1244 if (const DirectoryEntry *Dir = FileMgr.getDirectory(DirName))
1245 return loadModuleMapFile(Dir, IsSystem, IsFramework);
1247 return LMM_NoDirectory;
1250 HeaderSearch::LoadModuleMapResult
1251 HeaderSearch::loadModuleMapFile(const DirectoryEntry *Dir, bool IsSystem,
1253 auto KnownDir = DirectoryHasModuleMap.find(Dir);
1254 if (KnownDir != DirectoryHasModuleMap.end())
1255 return KnownDir->second? LMM_AlreadyLoaded : LMM_InvalidModuleMap;
1257 if (const FileEntry *ModuleMapFile = lookupModuleMapFile(Dir, IsFramework)) {
1258 LoadModuleMapResult Result = loadModuleMapFileImpl(ModuleMapFile, IsSystem);
1259 // Add Dir explicitly in case ModuleMapFile is in a subdirectory.
1260 // E.g. Foo.framework/Modules/module.modulemap
1261 // ^Dir ^ModuleMapFile
1262 if (Result == LMM_NewlyLoaded)
1263 DirectoryHasModuleMap[Dir] = true;
1266 return LMM_InvalidModuleMap;
1269 void HeaderSearch::collectAllModules(SmallVectorImpl<Module *> &Modules) {
1272 // Load module maps for each of the header search directories.
1273 for (unsigned Idx = 0, N = SearchDirs.size(); Idx != N; ++Idx) {
1274 bool IsSystem = SearchDirs[Idx].isSystemHeaderDirectory();
1275 if (SearchDirs[Idx].isFramework()) {
1277 SmallString<128> DirNative;
1278 llvm::sys::path::native(SearchDirs[Idx].getFrameworkDir()->getName(),
1281 // Search each of the ".framework" directories to load them as modules.
1282 for (llvm::sys::fs::directory_iterator Dir(DirNative.str(), EC), DirEnd;
1283 Dir != DirEnd && !EC; Dir.increment(EC)) {
1284 if (llvm::sys::path::extension(Dir->path()) != ".framework")
1287 const DirectoryEntry *FrameworkDir = FileMgr.getDirectory(Dir->path());
1291 // Load this framework module.
1292 loadFrameworkModule(llvm::sys::path::stem(Dir->path()), FrameworkDir,
1298 // FIXME: Deal with header maps.
1299 if (SearchDirs[Idx].isHeaderMap())
1302 // Try to load a module map file for the search directory.
1303 loadModuleMapFile(SearchDirs[Idx].getDir(), IsSystem, /*IsFramework*/false);
1305 // Try to load module map files for immediate subdirectories of this search
1307 loadSubdirectoryModuleMaps(SearchDirs[Idx]);
1310 // Populate the list of modules.
1311 for (ModuleMap::module_iterator M = ModMap.module_begin(),
1312 MEnd = ModMap.module_end();
1314 Modules.push_back(M->getValue());
1318 void HeaderSearch::loadTopLevelSystemModules() {
1319 // Load module maps for each of the header search directories.
1320 for (unsigned Idx = 0, N = SearchDirs.size(); Idx != N; ++Idx) {
1321 // We only care about normal header directories.
1322 if (!SearchDirs[Idx].isNormalDir()) {
1326 // Try to load a module map file for the search directory.
1327 loadModuleMapFile(SearchDirs[Idx].getDir(),
1328 SearchDirs[Idx].isSystemHeaderDirectory(),
1329 SearchDirs[Idx].isFramework());
1333 void HeaderSearch::loadSubdirectoryModuleMaps(DirectoryLookup &SearchDir) {
1334 if (SearchDir.haveSearchedAllModuleMaps())
1338 SmallString<128> DirNative;
1339 llvm::sys::path::native(SearchDir.getDir()->getName(), DirNative);
1340 for (llvm::sys::fs::directory_iterator Dir(DirNative.str(), EC), DirEnd;
1341 Dir != DirEnd && !EC; Dir.increment(EC)) {
1342 loadModuleMapFile(Dir->path(), SearchDir.isSystemHeaderDirectory(),
1343 SearchDir.isFramework());
1346 SearchDir.setSearchedAllModuleMaps(true);