1 //===--- InitHeaderSearch.cpp - Initialize header search paths ------------===//
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 InitHeaderSearch class.
12 //===----------------------------------------------------------------------===//
14 #include "clang/Basic/FileManager.h"
15 #include "clang/Basic/LangOptions.h"
16 #include "clang/Config/config.h" // C_INCLUDE_DIRS
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;
51 InitHeaderSearch(HeaderSearch &HS, bool verbose, StringRef sysroot)
52 : Headers(HS), Verbose(verbose), IncludeSysroot(sysroot),
53 HasSysroot(!(sysroot.empty() || sysroot == "/")) {
56 /// AddPath - Add the specified path to the specified group list, prefixing
57 /// the sysroot if used.
58 void AddPath(const Twine &Path, IncludeDirGroup Group, bool isFramework);
60 /// AddUnmappedPath - Add the specified path to the specified group list,
61 /// without performing any sysroot remapping.
62 void 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(Prefix, IsSystemHeader);
71 /// AddGnuCPlusPlusIncludePaths - Add the necessary paths to support a gnu
73 void AddGnuCPlusPlusIncludePaths(StringRef Base,
77 const llvm::Triple &triple);
79 /// AddMinGWCPlusPlusIncludePaths - Add the necessary paths to support a MinGW
81 void AddMinGWCPlusPlusIncludePaths(StringRef Base,
85 // AddDefaultCIncludePaths - Add paths that should always be searched.
86 void AddDefaultCIncludePaths(const llvm::Triple &triple,
87 const HeaderSearchOptions &HSOpts);
89 // AddDefaultCPlusPlusIncludePaths - Add paths that should be searched when
91 void AddDefaultCPlusPlusIncludePaths(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) {
108 #if defined(LLVM_ON_WIN32)
109 return !Path.empty() && llvm::sys::path::is_separator(Path[0]);
111 return llvm::sys::path::is_absolute(Path);
115 void 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 AddUnmappedPath(IncludeSysroot + Path, Group, isFramework);
128 AddUnmappedPath(Path, Group, isFramework);
131 void InitHeaderSearch::AddUnmappedPath(const Twine &Path, IncludeDirGroup Group,
133 assert(!Path.isTriviallyEmpty() && "can't handle empty path here");
135 FileManager &FM = Headers.getFileMgr();
136 SmallString<256> MappedPathStorage;
137 StringRef MappedPathStr = Path.toStringRef(MappedPathStorage);
139 // Compute the DirectoryLookup type.
140 SrcMgr::CharacteristicKind Type;
141 if (Group == Quoted || Group == Angled || Group == IndexHeaderMap) {
142 Type = SrcMgr::C_User;
143 } else if (Group == ExternCSystem) {
144 Type = SrcMgr::C_ExternCSystem;
146 Type = SrcMgr::C_System;
149 // If the directory exists, add it.
150 if (const DirectoryEntry *DE = FM.getDirectory(MappedPathStr)) {
151 IncludePath.push_back(
152 std::make_pair(Group, DirectoryLookup(DE, Type, isFramework)));
156 // Check to see if this is an apple-style headermap (which are not allowed to
159 if (const FileEntry *FE = FM.getFile(MappedPathStr)) {
160 if (const HeaderMap *HM = Headers.CreateHeaderMap(FE)) {
161 // It is a headermap, add it to the search path.
162 IncludePath.push_back(
163 std::make_pair(Group,
164 DirectoryLookup(HM, Type, Group == IndexHeaderMap)));
171 llvm::errs() << "ignoring nonexistent directory \""
172 << MappedPathStr << "\"\n";
175 void InitHeaderSearch::AddGnuCPlusPlusIncludePaths(StringRef Base,
179 const llvm::Triple &triple) {
181 AddPath(Base, CXXSystem, false);
183 // Add the multilib dirs
184 llvm::Triple::ArchType arch = triple.getArch();
185 bool is64bit = arch == llvm::Triple::ppc64 || arch == llvm::Triple::x86_64;
187 AddPath(Base + "/" + ArchDir + "/" + Dir64, CXXSystem, false);
189 AddPath(Base + "/" + ArchDir + "/" + Dir32, CXXSystem, false);
191 // Add the backward dir
192 AddPath(Base + "/backward", CXXSystem, false);
195 void InitHeaderSearch::AddMinGWCPlusPlusIncludePaths(StringRef Base,
198 AddPath(Base + "/" + Arch + "/" + Version + "/include/c++",
200 AddPath(Base + "/" + Arch + "/" + Version + "/include/c++/" + Arch,
202 AddPath(Base + "/" + Arch + "/" + Version + "/include/c++/backward",
206 void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
207 const HeaderSearchOptions &HSOpts) {
208 llvm::Triple::OSType os = triple.getOS();
210 if (HSOpts.UseStandardSystemIncludes) {
212 case llvm::Triple::CloudABI:
213 case llvm::Triple::FreeBSD:
214 case llvm::Triple::NetBSD:
215 case llvm::Triple::OpenBSD:
216 case llvm::Triple::NaCl:
217 case llvm::Triple::PS4:
218 case llvm::Triple::ELFIAMCU:
220 case llvm::Triple::Win32:
221 if (triple.getEnvironment() != llvm::Triple::Cygnus)
225 // FIXME: temporary hack: hard-coded paths.
226 AddPath("/usr/local/include", System, false);
231 // Builtin includes use #include_next directives and should be positioned
232 // just prior C include dirs.
233 if (HSOpts.UseBuiltinIncludes) {
234 // Ignore the sys root, we *always* look for clang headers relative to
236 SmallString<128> P = StringRef(HSOpts.ResourceDir);
237 llvm::sys::path::append(P, "include");
238 AddUnmappedPath(P, ExternCSystem, false);
241 // All remaining additions are for system include directories, early exit if
242 // we aren't using them.
243 if (!HSOpts.UseStandardSystemIncludes)
246 // Add dirs specified via 'configure --with-c-include-dirs'.
247 StringRef CIncludeDirs(C_INCLUDE_DIRS);
248 if (CIncludeDirs != "") {
249 SmallVector<StringRef, 5> dirs;
250 CIncludeDirs.split(dirs, ":");
251 for (StringRef dir : dirs)
252 AddPath(dir, ExternCSystem, false);
257 case llvm::Triple::Linux:
258 llvm_unreachable("Include management is handled in the driver.");
260 case llvm::Triple::CloudABI: {
261 // <sysroot>/<triple>/include
262 SmallString<128> P = StringRef(HSOpts.ResourceDir);
263 llvm::sys::path::append(P, "../../..", triple.str(), "include");
264 AddPath(P, System, false);
268 case llvm::Triple::Haiku:
269 AddPath("/boot/system/non-packaged/develop/headers", System, false);
270 AddPath("/boot/system/develop/headers/os", System, false);
271 AddPath("/boot/system/develop/headers/os/app", System, false);
272 AddPath("/boot/system/develop/headers/os/arch", System, false);
273 AddPath("/boot/system/develop/headers/os/device", System, false);
274 AddPath("/boot/system/develop/headers/os/drivers", System, false);
275 AddPath("/boot/system/develop/headers/os/game", System, false);
276 AddPath("/boot/system/develop/headers/os/interface", System, false);
277 AddPath("/boot/system/develop/headers/os/kernel", System, false);
278 AddPath("/boot/system/develop/headers/os/locale", System, false);
279 AddPath("/boot/system/develop/headers/os/mail", System, false);
280 AddPath("/boot/system/develop/headers/os/media", System, false);
281 AddPath("/boot/system/develop/headers/os/midi", System, false);
282 AddPath("/boot/system/develop/headers/os/midi2", System, false);
283 AddPath("/boot/system/develop/headers/os/net", System, false);
284 AddPath("/boot/system/develop/headers/os/opengl", System, false);
285 AddPath("/boot/system/develop/headers/os/storage", System, false);
286 AddPath("/boot/system/develop/headers/os/support", System, false);
287 AddPath("/boot/system/develop/headers/os/translation", System, false);
288 AddPath("/boot/system/develop/headers/os/add-ons/graphics", System, false);
289 AddPath("/boot/system/develop/headers/os/add-ons/input_server", System, false);
290 AddPath("/boot/system/develop/headers/os/add-ons/mail_daemon", System, false);
291 AddPath("/boot/system/develop/headers/os/add-ons/registrar", System, false);
292 AddPath("/boot/system/develop/headers/os/add-ons/screen_saver", System, false);
293 AddPath("/boot/system/develop/headers/os/add-ons/tracker", System, false);
294 AddPath("/boot/system/develop/headers/os/be_apps/Deskbar", System, false);
295 AddPath("/boot/system/develop/headers/os/be_apps/NetPositive", System, false);
296 AddPath("/boot/system/develop/headers/os/be_apps/Tracker", System, false);
297 AddPath("/boot/system/develop/headers/3rdparty", System, false);
298 AddPath("/boot/system/develop/headers/bsd", System, false);
299 AddPath("/boot/system/develop/headers/glibc", System, false);
300 AddPath("/boot/system/develop/headers/posix", System, false);
301 AddPath("/boot/system/develop/headers", System, false);
303 case llvm::Triple::RTEMS:
305 case llvm::Triple::Win32:
306 switch (triple.getEnvironment()) {
307 default: llvm_unreachable("Include management is handled in the driver.");
308 case llvm::Triple::Cygnus:
309 AddPath("/usr/include/w32api", System, false);
311 case llvm::Triple::GNU:
320 case llvm::Triple::CloudABI:
321 case llvm::Triple::RTEMS:
322 case llvm::Triple::NaCl:
323 case llvm::Triple::ELFIAMCU:
325 case llvm::Triple::PS4: {
326 // <isysroot> gets prepended later in AddPath().
327 std::string BaseSDKPath = "";
329 const char *envValue = getenv("SCE_ORBIS_SDK_DIR");
331 BaseSDKPath = envValue;
333 // HSOpts.ResourceDir variable contains the location of Clang's
335 // Assuming that Clang is configured for PS4 without
336 // --with-clang-resource-dir option, the location of Clang's resource
337 // files is <SDK_DIR>/host_tools/lib/clang
338 SmallString<128> P = StringRef(HSOpts.ResourceDir);
339 llvm::sys::path::append(P, "../../..");
340 BaseSDKPath = P.str();
343 AddPath(BaseSDKPath + "/target/include", System, false);
344 if (triple.isPS4CPU())
345 AddPath(BaseSDKPath + "/target/include_common", System, false);
349 AddPath("/usr/include", ExternCSystem, false);
354 void InitHeaderSearch::
355 AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple, const HeaderSearchOptions &HSOpts) {
356 llvm::Triple::OSType os = triple.getOS();
357 // FIXME: temporary hack: hard-coded paths.
359 if (triple.isOSDarwin()) {
360 switch (triple.getArch()) {
363 case llvm::Triple::ppc:
364 case llvm::Triple::ppc64:
365 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
366 "powerpc-apple-darwin10", "", "ppc64",
368 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.0.0",
369 "powerpc-apple-darwin10", "", "ppc64",
373 case llvm::Triple::x86:
374 case llvm::Triple::x86_64:
375 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
376 "i686-apple-darwin10", "", "x86_64", triple);
377 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.0.0",
378 "i686-apple-darwin8", "", "", triple);
381 case llvm::Triple::arm:
382 case llvm::Triple::thumb:
383 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
384 "arm-apple-darwin10", "v7", "", triple);
385 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
386 "arm-apple-darwin10", "v6", "", triple);
389 case llvm::Triple::aarch64:
390 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
391 "arm64-apple-darwin10", "", "", triple);
398 case llvm::Triple::Linux:
399 llvm_unreachable("Include management is handled in the driver.");
401 case llvm::Triple::Win32:
402 switch (triple.getEnvironment()) {
403 default: llvm_unreachable("Include management is handled in the driver.");
404 case llvm::Triple::Cygnus:
406 AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "4.7.3");
407 AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "4.5.3");
408 AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "4.3.4");
409 // g++-4 / Cygwin-1.5
410 AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "4.3.2");
414 case llvm::Triple::DragonFly:
415 AddPath("/usr/include/c++/5.0", CXXSystem, false);
417 case llvm::Triple::OpenBSD: {
418 std::string t = triple.getTriple();
419 if (t.substr(0, 6) == "x86_64")
420 t.replace(0, 6, "amd64");
421 AddGnuCPlusPlusIncludePaths("/usr/include/g++",
425 case llvm::Triple::Minix:
426 AddGnuCPlusPlusIncludePaths("/usr/gnu/include/c++/4.4.3",
434 void InitHeaderSearch::AddDefaultIncludePaths(const LangOptions &Lang,
435 const llvm::Triple &triple,
436 const HeaderSearchOptions &HSOpts) {
437 // NB: This code path is going away. All of the logic is moving into the
438 // driver which has the information necessary to do target-specific
439 // selections of default include paths. Each target which moves there will be
440 // exempted from this logic here until we can delete the entire pile of code.
441 switch (triple.getOS()) {
443 break; // Everything else continues to use this routine's logic.
445 case llvm::Triple::Linux:
448 case llvm::Triple::Win32:
449 if (triple.getEnvironment() != llvm::Triple::Cygnus ||
450 triple.isOSBinFormatMachO())
455 if (Lang.CPlusPlus && HSOpts.UseStandardCXXIncludes &&
456 HSOpts.UseStandardSystemIncludes) {
457 if (HSOpts.UseLibcxx) {
458 if (triple.isOSDarwin()) {
459 // On Darwin, libc++ may be installed alongside the compiler in
461 if (!HSOpts.ResourceDir.empty()) {
462 // Remove version from foo/lib/clang/version
463 StringRef NoVer = llvm::sys::path::parent_path(HSOpts.ResourceDir);
464 // Remove clang from foo/lib/clang
465 StringRef Lib = llvm::sys::path::parent_path(NoVer);
466 // Remove lib from foo/lib
467 SmallString<128> P = llvm::sys::path::parent_path(Lib);
469 // Get foo/include/c++/v1
470 llvm::sys::path::append(P, "include", "c++", "v1");
471 AddUnmappedPath(P, CXXSystem, false);
474 AddPath("/usr/include/c++/v1", CXXSystem, false);
476 AddDefaultCPlusPlusIncludePaths(triple, HSOpts);
480 AddDefaultCIncludePaths(triple, HSOpts);
482 // Add the default framework include paths on Darwin.
483 if (HSOpts.UseStandardSystemIncludes) {
484 if (triple.isOSDarwin()) {
485 AddPath("/System/Library/Frameworks", System, true);
486 AddPath("/Library/Frameworks", System, true);
491 /// RemoveDuplicates - If there are duplicate directory entries in the specified
492 /// search list, remove the later (dead) ones. Returns the number of non-system
493 /// headers removed, which is used to update NumAngled.
494 static unsigned RemoveDuplicates(std::vector<DirectoryLookup> &SearchList,
495 unsigned First, bool Verbose) {
496 llvm::SmallPtrSet<const DirectoryEntry *, 8> SeenDirs;
497 llvm::SmallPtrSet<const DirectoryEntry *, 8> SeenFrameworkDirs;
498 llvm::SmallPtrSet<const HeaderMap *, 8> SeenHeaderMaps;
499 unsigned NonSystemRemoved = 0;
500 for (unsigned i = First; i != SearchList.size(); ++i) {
501 unsigned DirToRemove = i;
503 const DirectoryLookup &CurEntry = SearchList[i];
505 if (CurEntry.isNormalDir()) {
506 // If this isn't the first time we've seen this dir, remove it.
507 if (SeenDirs.insert(CurEntry.getDir()).second)
509 } else if (CurEntry.isFramework()) {
510 // If this isn't the first time we've seen this framework dir, remove it.
511 if (SeenFrameworkDirs.insert(CurEntry.getFrameworkDir()).second)
514 assert(CurEntry.isHeaderMap() && "Not a headermap or normal dir?");
515 // If this isn't the first time we've seen this headermap, remove it.
516 if (SeenHeaderMaps.insert(CurEntry.getHeaderMap()).second)
520 // If we have a normal #include dir/framework/headermap that is shadowed
521 // later in the chain by a system include location, we actually want to
522 // ignore the user's request and drop the user dir... keeping the system
523 // dir. This is weird, but required to emulate GCC's search path correctly.
525 // Since dupes of system dirs are rare, just rescan to find the original
526 // that we're nuking instead of using a DenseMap.
527 if (CurEntry.getDirCharacteristic() != SrcMgr::C_User) {
528 // Find the dir that this is the same of.
530 for (FirstDir = First;; ++FirstDir) {
531 assert(FirstDir != i && "Didn't find dupe?");
533 const DirectoryLookup &SearchEntry = SearchList[FirstDir];
535 // If these are different lookup types, then they can't be the dupe.
536 if (SearchEntry.getLookupType() != CurEntry.getLookupType())
540 if (CurEntry.isNormalDir())
541 isSame = SearchEntry.getDir() == CurEntry.getDir();
542 else if (CurEntry.isFramework())
543 isSame = SearchEntry.getFrameworkDir() == CurEntry.getFrameworkDir();
545 assert(CurEntry.isHeaderMap() && "Not a headermap or normal dir?");
546 isSame = SearchEntry.getHeaderMap() == CurEntry.getHeaderMap();
553 // If the first dir in the search path is a non-system dir, zap it
554 // instead of the system one.
555 if (SearchList[FirstDir].getDirCharacteristic() == SrcMgr::C_User)
556 DirToRemove = FirstDir;
560 llvm::errs() << "ignoring duplicate directory \""
561 << CurEntry.getName() << "\"\n";
562 if (DirToRemove != i)
563 llvm::errs() << " as it is a non-system directory that duplicates "
564 << "a system directory\n";
566 if (DirToRemove != i)
569 // This is reached if the current entry is a duplicate. Remove the
570 // DirToRemove (usually the current dir).
571 SearchList.erase(SearchList.begin()+DirToRemove);
574 return NonSystemRemoved;
578 void InitHeaderSearch::Realize(const LangOptions &Lang) {
579 // Concatenate ANGLE+SYSTEM+AFTER chains together into SearchList.
580 std::vector<DirectoryLookup> SearchList;
581 SearchList.reserve(IncludePath.size());
583 // Quoted arguments go first.
584 for (auto &Include : IncludePath)
585 if (Include.first == Quoted)
586 SearchList.push_back(Include.second);
588 // Deduplicate and remember index.
589 RemoveDuplicates(SearchList, 0, Verbose);
590 unsigned NumQuoted = SearchList.size();
592 for (auto &Include : IncludePath)
593 if (Include.first == Angled || Include.first == IndexHeaderMap)
594 SearchList.push_back(Include.second);
596 RemoveDuplicates(SearchList, NumQuoted, Verbose);
597 unsigned NumAngled = SearchList.size();
599 for (auto &Include : IncludePath)
600 if (Include.first == System || Include.first == ExternCSystem ||
601 (!Lang.ObjC1 && !Lang.CPlusPlus && Include.first == CSystem) ||
602 (/*FIXME !Lang.ObjC1 && */ Lang.CPlusPlus &&
603 Include.first == CXXSystem) ||
604 (Lang.ObjC1 && !Lang.CPlusPlus && Include.first == ObjCSystem) ||
605 (Lang.ObjC1 && Lang.CPlusPlus && Include.first == ObjCXXSystem))
606 SearchList.push_back(Include.second);
608 for (auto &Include : IncludePath)
609 if (Include.first == After)
610 SearchList.push_back(Include.second);
612 // Remove duplicates across both the Angled and System directories. GCC does
613 // this and failing to remove duplicates across these two groups breaks
615 unsigned NonSystemRemoved = RemoveDuplicates(SearchList, NumQuoted, Verbose);
616 NumAngled -= NonSystemRemoved;
618 bool DontSearchCurDir = false; // TODO: set to true if -I- is set?
619 Headers.SetSearchPaths(SearchList, NumQuoted, NumAngled, DontSearchCurDir);
621 Headers.SetSystemHeaderPrefixes(SystemHeaderPrefixes);
623 // If verbose, print the list of directories that will be searched.
625 llvm::errs() << "#include \"...\" search starts here:\n";
626 for (unsigned i = 0, e = SearchList.size(); i != e; ++i) {
628 llvm::errs() << "#include <...> search starts here:\n";
629 StringRef Name = SearchList[i].getName();
631 if (SearchList[i].isNormalDir())
633 else if (SearchList[i].isFramework())
634 Suffix = " (framework directory)";
636 assert(SearchList[i].isHeaderMap() && "Unknown DirectoryLookup");
637 Suffix = " (headermap)";
639 llvm::errs() << " " << Name << Suffix << "\n";
641 llvm::errs() << "End of search list.\n";
645 void clang::ApplyHeaderSearchOptions(HeaderSearch &HS,
646 const HeaderSearchOptions &HSOpts,
647 const LangOptions &Lang,
648 const llvm::Triple &Triple) {
649 InitHeaderSearch Init(HS, HSOpts.Verbose, HSOpts.Sysroot);
651 // Add the user defined entries.
652 for (unsigned i = 0, e = HSOpts.UserEntries.size(); i != e; ++i) {
653 const HeaderSearchOptions::Entry &E = HSOpts.UserEntries[i];
654 if (E.IgnoreSysRoot) {
655 Init.AddUnmappedPath(E.Path, E.Group, E.IsFramework);
657 Init.AddPath(E.Path, E.Group, E.IsFramework);
661 Init.AddDefaultIncludePaths(Lang, Triple, HSOpts);
663 for (unsigned i = 0, e = HSOpts.SystemHeaderPrefixes.size(); i != e; ++i)
664 Init.AddSystemHeaderPrefix(HSOpts.SystemHeaderPrefixes[i].Prefix,
665 HSOpts.SystemHeaderPrefixes[i].IsSystemHeader);
667 if (HSOpts.UseBuiltinIncludes) {
668 // Set up the builtin include directory in the module map.
669 SmallString<128> P = StringRef(HSOpts.ResourceDir);
670 llvm::sys::path::append(P, "include");
671 if (const DirectoryEntry *Dir = HS.getFileMgr().getDirectory(P))
672 HS.getModuleMap().setBuiltinIncludeDir(Dir);