1 //===--- InitHeaderSearch.cpp - Initialize header search paths ------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file implements the InitHeaderSearch class.
11 //===----------------------------------------------------------------------===//
13 #include "clang/Basic/FileManager.h"
14 #include "clang/Basic/LangOptions.h"
15 #include "clang/Config/config.h" // C_INCLUDE_DIRS
16 #include "clang/Frontend/FrontendDiagnostic.h"
17 #include "clang/Frontend/Utils.h"
18 #include "clang/Lex/HeaderMap.h"
19 #include "clang/Lex/HeaderSearch.h"
20 #include "clang/Lex/HeaderSearchOptions.h"
21 #include "llvm/ADT/SmallPtrSet.h"
22 #include "llvm/ADT/SmallString.h"
23 #include "llvm/ADT/SmallVector.h"
24 #include "llvm/ADT/StringExtras.h"
25 #include "llvm/ADT/Triple.h"
26 #include "llvm/ADT/Twine.h"
27 #include "llvm/Support/ErrorHandling.h"
28 #include "llvm/Support/Path.h"
29 #include "llvm/Support/raw_ostream.h"
31 using namespace clang;
32 using namespace clang::frontend;
36 /// InitHeaderSearch - This class makes it easier to set the search paths of
37 /// a HeaderSearch object. InitHeaderSearch stores several search path lists
38 /// internally, which can be sent to a HeaderSearch object in one swoop.
39 class InitHeaderSearch {
40 std::vector<std::pair<IncludeDirGroup, DirectoryLookup> > IncludePath;
41 typedef std::vector<std::pair<IncludeDirGroup,
42 DirectoryLookup> >::const_iterator path_iterator;
43 std::vector<std::pair<std::string, bool> > SystemHeaderPrefixes;
44 HeaderSearch &Headers;
46 std::string IncludeSysroot;
50 InitHeaderSearch(HeaderSearch &HS, bool verbose, StringRef sysroot)
51 : Headers(HS), Verbose(verbose), IncludeSysroot(std::string(sysroot)),
52 HasSysroot(!(sysroot.empty() || sysroot == "/")) {}
54 /// AddPath - Add the specified path to the specified group list, prefixing
55 /// the sysroot if used.
56 /// Returns true if the path exists, false if it was ignored.
57 bool AddPath(const Twine &Path, IncludeDirGroup Group, bool isFramework);
59 /// AddUnmappedPath - Add the specified path to the specified group list,
60 /// without performing any sysroot remapping.
61 /// Returns true if the path exists, false if it was ignored.
62 bool AddUnmappedPath(const Twine &Path, IncludeDirGroup Group,
65 /// AddSystemHeaderPrefix - Add the specified prefix to the system header
67 void AddSystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) {
68 SystemHeaderPrefixes.emplace_back(std::string(Prefix), IsSystemHeader);
71 /// AddGnuCPlusPlusIncludePaths - Add the necessary paths to support a gnu
73 /// Returns true if the \p Base path was found, false if it does not exist.
74 bool AddGnuCPlusPlusIncludePaths(StringRef Base, StringRef ArchDir,
75 StringRef Dir32, StringRef Dir64,
76 const llvm::Triple &triple);
78 /// AddMinGWCPlusPlusIncludePaths - Add the necessary paths to support a MinGW
80 void AddMinGWCPlusPlusIncludePaths(StringRef Base,
84 // AddDefaultCIncludePaths - Add paths that should always be searched.
85 void AddDefaultCIncludePaths(const llvm::Triple &triple,
86 const HeaderSearchOptions &HSOpts);
88 // AddDefaultCPlusPlusIncludePaths - Add paths that should be searched when
90 void AddDefaultCPlusPlusIncludePaths(const LangOptions &LangOpts,
91 const llvm::Triple &triple,
92 const HeaderSearchOptions &HSOpts);
94 /// AddDefaultSystemIncludePaths - Adds the default system include paths so
95 /// that e.g. stdio.h is found.
96 void AddDefaultIncludePaths(const LangOptions &Lang,
97 const llvm::Triple &triple,
98 const HeaderSearchOptions &HSOpts);
100 /// Realize - Merges all search path lists into one list and send it to
102 void Realize(const LangOptions &Lang);
105 } // end anonymous namespace.
107 static bool CanPrefixSysroot(StringRef Path) {
109 return !Path.empty() && llvm::sys::path::is_separator(Path[0]);
111 return llvm::sys::path::is_absolute(Path);
115 bool InitHeaderSearch::AddPath(const Twine &Path, IncludeDirGroup Group,
117 // Add the path with sysroot prepended, if desired and this is a system header
120 SmallString<256> MappedPathStorage;
121 StringRef MappedPathStr = Path.toStringRef(MappedPathStorage);
122 if (CanPrefixSysroot(MappedPathStr)) {
123 return AddUnmappedPath(IncludeSysroot + Path, Group, isFramework);
127 return AddUnmappedPath(Path, Group, isFramework);
130 bool InitHeaderSearch::AddUnmappedPath(const Twine &Path, IncludeDirGroup Group,
132 assert(!Path.isTriviallyEmpty() && "can't handle empty path here");
134 FileManager &FM = Headers.getFileMgr();
135 SmallString<256> MappedPathStorage;
136 StringRef MappedPathStr = Path.toStringRef(MappedPathStorage);
138 // If use system headers while cross-compiling, emit the warning.
139 if (HasSysroot && (MappedPathStr.startswith("/usr/include") ||
140 MappedPathStr.startswith("/usr/local/include"))) {
141 Headers.getDiags().Report(diag::warn_poison_system_directories)
145 // Compute the DirectoryLookup type.
146 SrcMgr::CharacteristicKind Type;
147 if (Group == Quoted || Group == Angled || Group == IndexHeaderMap) {
148 Type = SrcMgr::C_User;
149 } else if (Group == ExternCSystem) {
150 Type = SrcMgr::C_ExternCSystem;
152 Type = SrcMgr::C_System;
155 // If the directory exists, add it.
156 if (auto DE = FM.getOptionalDirectoryRef(MappedPathStr)) {
157 IncludePath.push_back(
158 std::make_pair(Group, DirectoryLookup(*DE, Type, isFramework)));
162 // Check to see if this is an apple-style headermap (which are not allowed to
165 if (auto FE = FM.getFile(MappedPathStr)) {
166 if (const HeaderMap *HM = Headers.CreateHeaderMap(*FE)) {
167 // It is a headermap, add it to the search path.
168 IncludePath.push_back(
169 std::make_pair(Group,
170 DirectoryLookup(HM, Type, Group == IndexHeaderMap)));
177 llvm::errs() << "ignoring nonexistent directory \""
178 << MappedPathStr << "\"\n";
182 bool InitHeaderSearch::AddGnuCPlusPlusIncludePaths(StringRef Base,
186 const llvm::Triple &triple) {
188 bool IsBaseFound = AddPath(Base, CXXSystem, false);
190 // Add the multilib dirs
191 llvm::Triple::ArchType arch = triple.getArch();
192 bool is64bit = arch == llvm::Triple::ppc64 || arch == llvm::Triple::x86_64;
194 AddPath(Base + "/" + ArchDir + "/" + Dir64, CXXSystem, false);
196 AddPath(Base + "/" + ArchDir + "/" + Dir32, CXXSystem, false);
198 // Add the backward dir
199 AddPath(Base + "/backward", CXXSystem, false);
203 void InitHeaderSearch::AddMinGWCPlusPlusIncludePaths(StringRef Base,
206 AddPath(Base + "/" + Arch + "/" + Version + "/include/c++",
208 AddPath(Base + "/" + Arch + "/" + Version + "/include/c++/" + Arch,
210 AddPath(Base + "/" + Arch + "/" + Version + "/include/c++/backward",
214 void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
215 const HeaderSearchOptions &HSOpts) {
216 llvm::Triple::OSType os = triple.getOS();
218 if (triple.isOSDarwin()) {
219 llvm_unreachable("Include management is handled in the driver.");
222 if (HSOpts.UseStandardSystemIncludes) {
224 case llvm::Triple::CloudABI:
225 case llvm::Triple::FreeBSD:
226 case llvm::Triple::NetBSD:
227 case llvm::Triple::OpenBSD:
228 case llvm::Triple::NaCl:
229 case llvm::Triple::PS4:
230 case llvm::Triple::ELFIAMCU:
231 case llvm::Triple::Fuchsia:
233 case llvm::Triple::Win32:
234 if (triple.getEnvironment() != llvm::Triple::Cygnus)
238 // FIXME: temporary hack: hard-coded paths.
239 AddPath("/usr/local/include", System, false);
244 // Builtin includes use #include_next directives and should be positioned
245 // just prior C include dirs.
246 if (HSOpts.UseBuiltinIncludes) {
247 // Ignore the sys root, we *always* look for clang headers relative to
249 SmallString<128> P = StringRef(HSOpts.ResourceDir);
250 llvm::sys::path::append(P, "include");
251 AddUnmappedPath(P, ExternCSystem, false);
254 // All remaining additions are for system include directories, early exit if
255 // we aren't using them.
256 if (!HSOpts.UseStandardSystemIncludes)
259 // Add dirs specified via 'configure --with-c-include-dirs'.
260 StringRef CIncludeDirs(C_INCLUDE_DIRS);
261 if (CIncludeDirs != "") {
262 SmallVector<StringRef, 5> dirs;
263 CIncludeDirs.split(dirs, ":");
264 for (StringRef dir : dirs)
265 AddPath(dir, ExternCSystem, false);
270 case llvm::Triple::Linux:
271 case llvm::Triple::Hurd:
272 case llvm::Triple::Solaris:
273 case llvm::Triple::OpenBSD:
274 llvm_unreachable("Include management is handled in the driver.");
276 case llvm::Triple::CloudABI: {
277 // <sysroot>/<triple>/include
278 SmallString<128> P = StringRef(HSOpts.ResourceDir);
279 llvm::sys::path::append(P, "../../..", triple.str(), "include");
280 AddPath(P, System, false);
284 case llvm::Triple::Haiku:
285 AddPath("/boot/system/non-packaged/develop/headers", System, false);
286 AddPath("/boot/system/develop/headers/os", System, false);
287 AddPath("/boot/system/develop/headers/os/app", System, false);
288 AddPath("/boot/system/develop/headers/os/arch", System, false);
289 AddPath("/boot/system/develop/headers/os/device", System, false);
290 AddPath("/boot/system/develop/headers/os/drivers", System, false);
291 AddPath("/boot/system/develop/headers/os/game", System, false);
292 AddPath("/boot/system/develop/headers/os/interface", System, false);
293 AddPath("/boot/system/develop/headers/os/kernel", System, false);
294 AddPath("/boot/system/develop/headers/os/locale", System, false);
295 AddPath("/boot/system/develop/headers/os/mail", System, false);
296 AddPath("/boot/system/develop/headers/os/media", System, false);
297 AddPath("/boot/system/develop/headers/os/midi", System, false);
298 AddPath("/boot/system/develop/headers/os/midi2", System, false);
299 AddPath("/boot/system/develop/headers/os/net", System, false);
300 AddPath("/boot/system/develop/headers/os/opengl", System, false);
301 AddPath("/boot/system/develop/headers/os/storage", System, false);
302 AddPath("/boot/system/develop/headers/os/support", System, false);
303 AddPath("/boot/system/develop/headers/os/translation", System, false);
304 AddPath("/boot/system/develop/headers/os/add-ons/graphics", System, false);
305 AddPath("/boot/system/develop/headers/os/add-ons/input_server", System, false);
306 AddPath("/boot/system/develop/headers/os/add-ons/mail_daemon", System, false);
307 AddPath("/boot/system/develop/headers/os/add-ons/registrar", System, false);
308 AddPath("/boot/system/develop/headers/os/add-ons/screen_saver", System, false);
309 AddPath("/boot/system/develop/headers/os/add-ons/tracker", System, false);
310 AddPath("/boot/system/develop/headers/os/be_apps/Deskbar", System, false);
311 AddPath("/boot/system/develop/headers/os/be_apps/NetPositive", System, false);
312 AddPath("/boot/system/develop/headers/os/be_apps/Tracker", System, false);
313 AddPath("/boot/system/develop/headers/3rdparty", System, false);
314 AddPath("/boot/system/develop/headers/bsd", System, false);
315 AddPath("/boot/system/develop/headers/glibc", System, false);
316 AddPath("/boot/system/develop/headers/posix", System, false);
317 AddPath("/boot/system/develop/headers", System, false);
319 case llvm::Triple::RTEMS:
321 case llvm::Triple::Win32:
322 switch (triple.getEnvironment()) {
323 default: llvm_unreachable("Include management is handled in the driver.");
324 case llvm::Triple::Cygnus:
325 AddPath("/usr/include/w32api", System, false);
327 case llvm::Triple::GNU:
336 case llvm::Triple::CloudABI:
337 case llvm::Triple::RTEMS:
338 case llvm::Triple::NaCl:
339 case llvm::Triple::ELFIAMCU:
340 case llvm::Triple::Fuchsia:
342 case llvm::Triple::PS4: {
343 // <isysroot> gets prepended later in AddPath().
344 std::string BaseSDKPath = "";
346 const char *envValue = getenv("SCE_ORBIS_SDK_DIR");
348 BaseSDKPath = envValue;
350 // HSOpts.ResourceDir variable contains the location of Clang's
352 // Assuming that Clang is configured for PS4 without
353 // --with-clang-resource-dir option, the location of Clang's resource
354 // files is <SDK_DIR>/host_tools/lib/clang
355 SmallString<128> P = StringRef(HSOpts.ResourceDir);
356 llvm::sys::path::append(P, "../../..");
357 BaseSDKPath = std::string(P.str());
360 AddPath(BaseSDKPath + "/target/include", System, false);
361 if (triple.isPS4CPU())
362 AddPath(BaseSDKPath + "/target/include_common", System, false);
366 AddPath("/usr/include", ExternCSystem, false);
371 void InitHeaderSearch::AddDefaultCPlusPlusIncludePaths(
372 const LangOptions &LangOpts, const llvm::Triple &triple,
373 const HeaderSearchOptions &HSOpts) {
374 llvm::Triple::OSType os = triple.getOS();
375 // FIXME: temporary hack: hard-coded paths.
377 if (triple.isOSDarwin()) {
378 llvm_unreachable("Include management is handled in the driver.");
382 case llvm::Triple::Linux:
383 case llvm::Triple::Hurd:
384 case llvm::Triple::Solaris:
385 case llvm::Triple::AIX:
386 llvm_unreachable("Include management is handled in the driver.");
388 case llvm::Triple::Win32:
389 switch (triple.getEnvironment()) {
390 default: llvm_unreachable("Include management is handled in the driver.");
391 case llvm::Triple::Cygnus:
393 AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "4.7.3");
394 AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "4.5.3");
395 AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "4.3.4");
396 // g++-4 / Cygwin-1.5
397 AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "4.3.2");
401 case llvm::Triple::DragonFly:
402 AddPath("/usr/include/c++/5.0", CXXSystem, false);
404 case llvm::Triple::Minix:
405 AddGnuCPlusPlusIncludePaths("/usr/gnu/include/c++/4.4.3",
413 void InitHeaderSearch::AddDefaultIncludePaths(const LangOptions &Lang,
414 const llvm::Triple &triple,
415 const HeaderSearchOptions &HSOpts) {
416 // NB: This code path is going away. All of the logic is moving into the
417 // driver which has the information necessary to do target-specific
418 // selections of default include paths. Each target which moves there will be
419 // exempted from this logic here until we can delete the entire pile of code.
420 switch (triple.getOS()) {
422 break; // Everything else continues to use this routine's logic.
424 case llvm::Triple::Emscripten:
425 case llvm::Triple::Linux:
426 case llvm::Triple::Hurd:
427 case llvm::Triple::OpenBSD:
428 case llvm::Triple::Solaris:
429 case llvm::Triple::WASI:
430 case llvm::Triple::AIX:
433 case llvm::Triple::Win32:
434 if (triple.getEnvironment() != llvm::Triple::Cygnus ||
435 triple.isOSBinFormatMachO())
439 case llvm::Triple::UnknownOS:
445 // All header search logic is handled in the Driver for Darwin.
446 if (triple.isOSDarwin()) {
447 if (HSOpts.UseStandardSystemIncludes) {
448 // Add the default framework include paths on Darwin.
449 AddPath("/System/Library/Frameworks", System, true);
450 AddPath("/Library/Frameworks", System, true);
455 if (Lang.CPlusPlus && !Lang.AsmPreprocessor &&
456 HSOpts.UseStandardCXXIncludes && HSOpts.UseStandardSystemIncludes) {
457 if (HSOpts.UseLibcxx) {
458 AddPath("/usr/include/c++/v1", CXXSystem, false);
460 AddDefaultCPlusPlusIncludePaths(Lang, triple, HSOpts);
464 AddDefaultCIncludePaths(triple, HSOpts);
467 /// RemoveDuplicates - If there are duplicate directory entries in the specified
468 /// search list, remove the later (dead) ones. Returns the number of non-system
469 /// headers removed, which is used to update NumAngled.
470 static unsigned RemoveDuplicates(std::vector<DirectoryLookup> &SearchList,
471 unsigned First, bool Verbose) {
472 llvm::SmallPtrSet<const DirectoryEntry *, 8> SeenDirs;
473 llvm::SmallPtrSet<const DirectoryEntry *, 8> SeenFrameworkDirs;
474 llvm::SmallPtrSet<const HeaderMap *, 8> SeenHeaderMaps;
475 unsigned NonSystemRemoved = 0;
476 for (unsigned i = First; i != SearchList.size(); ++i) {
477 unsigned DirToRemove = i;
479 const DirectoryLookup &CurEntry = SearchList[i];
481 if (CurEntry.isNormalDir()) {
482 // If this isn't the first time we've seen this dir, remove it.
483 if (SeenDirs.insert(CurEntry.getDir()).second)
485 } else if (CurEntry.isFramework()) {
486 // If this isn't the first time we've seen this framework dir, remove it.
487 if (SeenFrameworkDirs.insert(CurEntry.getFrameworkDir()).second)
490 assert(CurEntry.isHeaderMap() && "Not a headermap or normal dir?");
491 // If this isn't the first time we've seen this headermap, remove it.
492 if (SeenHeaderMaps.insert(CurEntry.getHeaderMap()).second)
496 // If we have a normal #include dir/framework/headermap that is shadowed
497 // later in the chain by a system include location, we actually want to
498 // ignore the user's request and drop the user dir... keeping the system
499 // dir. This is weird, but required to emulate GCC's search path correctly.
501 // Since dupes of system dirs are rare, just rescan to find the original
502 // that we're nuking instead of using a DenseMap.
503 if (CurEntry.getDirCharacteristic() != SrcMgr::C_User) {
504 // Find the dir that this is the same of.
506 for (FirstDir = First;; ++FirstDir) {
507 assert(FirstDir != i && "Didn't find dupe?");
509 const DirectoryLookup &SearchEntry = SearchList[FirstDir];
511 // If these are different lookup types, then they can't be the dupe.
512 if (SearchEntry.getLookupType() != CurEntry.getLookupType())
516 if (CurEntry.isNormalDir())
517 isSame = SearchEntry.getDir() == CurEntry.getDir();
518 else if (CurEntry.isFramework())
519 isSame = SearchEntry.getFrameworkDir() == CurEntry.getFrameworkDir();
521 assert(CurEntry.isHeaderMap() && "Not a headermap or normal dir?");
522 isSame = SearchEntry.getHeaderMap() == CurEntry.getHeaderMap();
529 // If the first dir in the search path is a non-system dir, zap it
530 // instead of the system one.
531 if (SearchList[FirstDir].getDirCharacteristic() == SrcMgr::C_User)
532 DirToRemove = FirstDir;
536 llvm::errs() << "ignoring duplicate directory \""
537 << CurEntry.getName() << "\"\n";
538 if (DirToRemove != i)
539 llvm::errs() << " as it is a non-system directory that duplicates "
540 << "a system directory\n";
542 if (DirToRemove != i)
545 // This is reached if the current entry is a duplicate. Remove the
546 // DirToRemove (usually the current dir).
547 SearchList.erase(SearchList.begin()+DirToRemove);
550 return NonSystemRemoved;
554 void InitHeaderSearch::Realize(const LangOptions &Lang) {
555 // Concatenate ANGLE+SYSTEM+AFTER chains together into SearchList.
556 std::vector<DirectoryLookup> SearchList;
557 SearchList.reserve(IncludePath.size());
559 // Quoted arguments go first.
560 for (auto &Include : IncludePath)
561 if (Include.first == Quoted)
562 SearchList.push_back(Include.second);
564 // Deduplicate and remember index.
565 RemoveDuplicates(SearchList, 0, Verbose);
566 unsigned NumQuoted = SearchList.size();
568 for (auto &Include : IncludePath)
569 if (Include.first == Angled || Include.first == IndexHeaderMap)
570 SearchList.push_back(Include.second);
572 RemoveDuplicates(SearchList, NumQuoted, Verbose);
573 unsigned NumAngled = SearchList.size();
575 for (auto &Include : IncludePath)
576 if (Include.first == System || Include.first == ExternCSystem ||
577 (!Lang.ObjC && !Lang.CPlusPlus && Include.first == CSystem) ||
578 (/*FIXME !Lang.ObjC && */ Lang.CPlusPlus &&
579 Include.first == CXXSystem) ||
580 (Lang.ObjC && !Lang.CPlusPlus && Include.first == ObjCSystem) ||
581 (Lang.ObjC && Lang.CPlusPlus && Include.first == ObjCXXSystem))
582 SearchList.push_back(Include.second);
584 for (auto &Include : IncludePath)
585 if (Include.first == After)
586 SearchList.push_back(Include.second);
588 // Remove duplicates across both the Angled and System directories. GCC does
589 // this and failing to remove duplicates across these two groups breaks
591 unsigned NonSystemRemoved = RemoveDuplicates(SearchList, NumQuoted, Verbose);
592 NumAngled -= NonSystemRemoved;
594 bool DontSearchCurDir = false; // TODO: set to true if -I- is set?
595 Headers.SetSearchPaths(SearchList, NumQuoted, NumAngled, DontSearchCurDir);
597 Headers.SetSystemHeaderPrefixes(SystemHeaderPrefixes);
599 // If verbose, print the list of directories that will be searched.
601 llvm::errs() << "#include \"...\" search starts here:\n";
602 for (unsigned i = 0, e = SearchList.size(); i != e; ++i) {
604 llvm::errs() << "#include <...> search starts here:\n";
605 StringRef Name = SearchList[i].getName();
607 if (SearchList[i].isNormalDir())
609 else if (SearchList[i].isFramework())
610 Suffix = " (framework directory)";
612 assert(SearchList[i].isHeaderMap() && "Unknown DirectoryLookup");
613 Suffix = " (headermap)";
615 llvm::errs() << " " << Name << Suffix << "\n";
617 llvm::errs() << "End of search list.\n";
621 void clang::ApplyHeaderSearchOptions(HeaderSearch &HS,
622 const HeaderSearchOptions &HSOpts,
623 const LangOptions &Lang,
624 const llvm::Triple &Triple) {
625 InitHeaderSearch Init(HS, HSOpts.Verbose, HSOpts.Sysroot);
627 // Add the user defined entries.
628 for (unsigned i = 0, e = HSOpts.UserEntries.size(); i != e; ++i) {
629 const HeaderSearchOptions::Entry &E = HSOpts.UserEntries[i];
630 if (E.IgnoreSysRoot) {
631 Init.AddUnmappedPath(E.Path, E.Group, E.IsFramework);
633 Init.AddPath(E.Path, E.Group, E.IsFramework);
637 Init.AddDefaultIncludePaths(Lang, Triple, HSOpts);
639 for (unsigned i = 0, e = HSOpts.SystemHeaderPrefixes.size(); i != e; ++i)
640 Init.AddSystemHeaderPrefix(HSOpts.SystemHeaderPrefixes[i].Prefix,
641 HSOpts.SystemHeaderPrefixes[i].IsSystemHeader);
643 if (HSOpts.UseBuiltinIncludes) {
644 // Set up the builtin include directory in the module map.
645 SmallString<128> P = StringRef(HSOpts.ResourceDir);
646 llvm::sys::path::append(P, "include");
647 if (auto Dir = HS.getFileMgr().getDirectory(P))
648 HS.getModuleMap().setBuiltinIncludeDir(*Dir);