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 #ifdef HAVE_CLANG_CONFIG_H
15 # include "clang/Config/config.h"
18 #include "clang/Frontend/Utils.h"
19 #include "clang/Basic/FileManager.h"
20 #include "clang/Basic/LangOptions.h"
21 #include "clang/Basic/Version.h"
22 #include "clang/Frontend/HeaderSearchOptions.h"
23 #include "clang/Lex/HeaderSearch.h"
24 #include "llvm/ADT/SmallString.h"
25 #include "llvm/ADT/SmallPtrSet.h"
26 #include "llvm/ADT/SmallVector.h"
27 #include "llvm/ADT/StringExtras.h"
28 #include "llvm/ADT/Triple.h"
29 #include "llvm/ADT/Twine.h"
30 #include "llvm/Support/raw_ostream.h"
31 #include "llvm/Support/Path.h"
32 #include "llvm/Config/config.h"
34 #define WIN32_LEAN_AND_MEAN 1
40 using namespace clang;
41 using namespace clang::frontend;
45 /// InitHeaderSearch - This class makes it easier to set the search paths of
46 /// a HeaderSearch object. InitHeaderSearch stores several search path lists
47 /// internally, which can be sent to a HeaderSearch object in one swoop.
48 class InitHeaderSearch {
49 std::vector<std::pair<IncludeDirGroup, DirectoryLookup> > IncludePath;
50 typedef std::vector<std::pair<IncludeDirGroup,
51 DirectoryLookup> >::const_iterator path_iterator;
52 HeaderSearch &Headers;
54 std::string IncludeSysroot;
55 bool IsNotEmptyOrRoot;
59 InitHeaderSearch(HeaderSearch &HS, bool verbose, StringRef sysroot)
60 : Headers(HS), Verbose(verbose), IncludeSysroot(sysroot),
61 IsNotEmptyOrRoot(!(sysroot.empty() || sysroot == "/")) {
64 /// AddPath - Add the specified path to the specified group list.
65 void AddPath(const Twine &Path, IncludeDirGroup Group,
66 bool isCXXAware, bool isUserSupplied,
67 bool isFramework, bool IgnoreSysRoot = false);
69 /// AddGnuCPlusPlusIncludePaths - Add the necessary paths to support a gnu
71 void AddGnuCPlusPlusIncludePaths(StringRef Base,
75 const llvm::Triple &triple);
77 /// AddMinGWCPlusPlusIncludePaths - Add the necessary paths to support a MinGW
79 void AddMinGWCPlusPlusIncludePaths(StringRef Base,
83 /// AddMinGW64CXXPaths - Add the necessary paths to support
84 /// libstdc++ of x86_64-w64-mingw32 aka mingw-w64.
85 void AddMinGW64CXXPaths(StringRef Base,
88 // AddDefaultCIncludePaths - Add paths that should always be searched.
89 void AddDefaultCIncludePaths(const llvm::Triple &triple,
90 const HeaderSearchOptions &HSOpts);
92 // AddDefaultCPlusPlusIncludePaths - Add paths that should be searched when
94 void AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple,
95 const HeaderSearchOptions &HSOpts);
97 /// AddDefaultSystemIncludePaths - Adds the default system include paths so
98 /// that e.g. stdio.h is found.
99 void AddDefaultIncludePaths(const LangOptions &Lang,
100 const llvm::Triple &triple,
101 const HeaderSearchOptions &HSOpts);
103 /// Realize - Merges all search path lists into one list and send it to
105 void Realize(const LangOptions &Lang);
108 } // end anonymous namespace.
110 void InitHeaderSearch::AddPath(const Twine &Path,
111 IncludeDirGroup Group, bool isCXXAware,
112 bool isUserSupplied, bool isFramework,
113 bool IgnoreSysRoot) {
114 assert(!Path.isTriviallyEmpty() && "can't handle empty path here");
115 FileManager &FM = Headers.getFileMgr();
117 // Compute the actual path, taking into consideration -isysroot.
118 llvm::SmallString<256> MappedPathStorage;
119 StringRef MappedPathStr = Path.toStringRef(MappedPathStorage);
122 if ((Group == System || Group == CXXSystem) && !IgnoreSysRoot &&
124 !MappedPathStr.empty() &&
125 llvm::sys::path::is_separator(MappedPathStr[0]) &&
127 llvm::sys::path::is_absolute(MappedPathStr) &&
130 MappedPathStorage.clear();
132 (IncludeSysroot + Path).toStringRef(MappedPathStorage);
135 // Compute the DirectoryLookup type.
136 SrcMgr::CharacteristicKind Type;
137 if (Group == Quoted || Group == Angled || Group == IndexHeaderMap)
138 Type = SrcMgr::C_User;
140 Type = SrcMgr::C_System;
142 Type = SrcMgr::C_ExternCSystem;
145 // If the directory exists, add it.
146 if (const DirectoryEntry *DE = FM.getDirectory(MappedPathStr)) {
147 IncludePath.push_back(std::make_pair(Group, DirectoryLookup(DE, Type,
148 isUserSupplied, isFramework)));
152 // Check to see if this is an apple-style headermap (which are not allowed to
155 if (const FileEntry *FE = FM.getFile(MappedPathStr)) {
156 if (const HeaderMap *HM = Headers.CreateHeaderMap(FE)) {
157 // It is a headermap, add it to the search path.
158 IncludePath.push_back(std::make_pair(Group, DirectoryLookup(HM, Type,
159 isUserSupplied, Group == IndexHeaderMap)));
166 llvm::errs() << "ignoring nonexistent directory \""
167 << MappedPathStr << "\"\n";
170 void InitHeaderSearch::AddGnuCPlusPlusIncludePaths(StringRef Base,
174 const llvm::Triple &triple) {
176 AddPath(Base, CXXSystem, true, false, false);
178 // Add the multilib dirs
179 llvm::Triple::ArchType arch = triple.getArch();
180 bool is64bit = arch == llvm::Triple::ppc64 || arch == llvm::Triple::x86_64;
182 AddPath(Base + "/" + ArchDir + "/" + Dir64, CXXSystem, true, false, false);
184 AddPath(Base + "/" + ArchDir + "/" + Dir32, CXXSystem, true, false, false);
186 // Add the backward dir
187 AddPath(Base + "/backward", CXXSystem, true, false, false);
190 void InitHeaderSearch::AddMinGWCPlusPlusIncludePaths(StringRef Base,
193 AddPath(Base + "/" + Arch + "/" + Version + "/include/c++",
194 CXXSystem, true, false, false);
195 AddPath(Base + "/" + Arch + "/" + Version + "/include/c++/" + Arch,
196 CXXSystem, true, false, false);
197 AddPath(Base + "/" + Arch + "/" + Version + "/include/c++/backward",
198 CXXSystem, true, false, false);
201 void InitHeaderSearch::AddMinGW64CXXPaths(StringRef Base,
203 // Assumes Base is HeaderSearchOpts' ResourceDir
204 AddPath(Base + "/../../../include/c++/" + Version,
205 CXXSystem, true, false, false);
206 AddPath(Base + "/../../../include/c++/" + Version + "/x86_64-w64-mingw32",
207 CXXSystem, true, false, false);
208 AddPath(Base + "/../../../include/c++/" + Version + "/i686-w64-mingw32",
209 CXXSystem, true, false, false);
210 AddPath(Base + "/../../../include/c++/" + Version + "/backward",
211 CXXSystem, true, false, false);
214 // FIXME: This probably should goto to some platform utils place.
217 // Read registry string.
218 // This also supports a means to look for high-versioned keys by use
219 // of a $VERSION placeholder in the key path.
220 // $VERSION in the key path is a placeholder for the version number,
221 // causing the highest value path to be searched for and used.
222 // I.e. "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\$VERSION".
223 // There can be additional characters in the component. Only the numberic
224 // characters are compared.
225 static bool getSystemRegistryString(const char *keyPath, const char *valueName,
226 char *value, size_t maxLength) {
227 HKEY hRootKey = NULL;
229 const char* subKey = NULL;
231 DWORD valueSize = maxLength - 1;
233 bool returnValue = false;
235 if (strncmp(keyPath, "HKEY_CLASSES_ROOT\\", 18) == 0) {
236 hRootKey = HKEY_CLASSES_ROOT;
237 subKey = keyPath + 18;
238 } else if (strncmp(keyPath, "HKEY_USERS\\", 11) == 0) {
239 hRootKey = HKEY_USERS;
240 subKey = keyPath + 11;
241 } else if (strncmp(keyPath, "HKEY_LOCAL_MACHINE\\", 19) == 0) {
242 hRootKey = HKEY_LOCAL_MACHINE;
243 subKey = keyPath + 19;
244 } else if (strncmp(keyPath, "HKEY_CURRENT_USER\\", 18) == 0) {
245 hRootKey = HKEY_CURRENT_USER;
246 subKey = keyPath + 18;
251 const char *placeHolder = strstr(subKey, "$VERSION");
254 // If we have a $VERSION placeholder, do the highest-version search.
256 const char *keyEnd = placeHolder - 1;
257 const char *nextKey = placeHolder;
258 // Find end of previous key.
259 while ((keyEnd > subKey) && (*keyEnd != '\\'))
261 // Find end of key containing $VERSION.
262 while (*nextKey && (*nextKey != '\\'))
264 size_t partialKeyLength = keyEnd - subKey;
265 char partialKey[256];
266 if (partialKeyLength > sizeof(partialKey))
267 partialKeyLength = sizeof(partialKey);
268 strncpy(partialKey, subKey, partialKeyLength);
269 partialKey[partialKeyLength] = '\0';
271 lResult = RegOpenKeyEx(hRootKey, partialKey, 0, KEY_READ, &hTopKey);
272 if (lResult == ERROR_SUCCESS) {
275 double bestValue = 0.0;
276 DWORD index, size = sizeof(keyName) - 1;
277 for (index = 0; RegEnumKeyEx(hTopKey, index, keyName, &size, NULL,
278 NULL, NULL, NULL) == ERROR_SUCCESS; index++) {
279 const char *sp = keyName;
280 while (*sp && !isdigit(*sp))
284 const char *ep = sp + 1;
285 while (*ep && (isdigit(*ep) || (*ep == '.')))
288 strncpy(numBuf, sp, sizeof(numBuf) - 1);
289 numBuf[sizeof(numBuf) - 1] = '\0';
290 double value = strtod(numBuf, NULL);
291 if (value > bestValue) {
292 bestIndex = (int)index;
294 strcpy(bestName, keyName);
296 size = sizeof(keyName) - 1;
298 // If we found the highest versioned key, open the key and get the value.
299 if (bestIndex != -1) {
300 // Append rest of key.
301 strncat(bestName, nextKey, sizeof(bestName) - 1);
302 bestName[sizeof(bestName) - 1] = '\0';
303 // Open the chosen key path remainder.
304 lResult = RegOpenKeyEx(hTopKey, bestName, 0, KEY_READ, &hKey);
305 if (lResult == ERROR_SUCCESS) {
306 lResult = RegQueryValueEx(hKey, valueName, NULL, &valueType,
307 (LPBYTE)value, &valueSize);
308 if (lResult == ERROR_SUCCESS)
313 RegCloseKey(hTopKey);
317 lResult = RegOpenKeyEx(hRootKey, subKey, 0, KEY_READ, &hKey);
318 if (lResult == ERROR_SUCCESS) {
319 lResult = RegQueryValueEx(hKey, valueName, NULL, &valueType,
320 (LPBYTE)value, &valueSize);
321 if (lResult == ERROR_SUCCESS)
329 // Read registry string.
330 static bool getSystemRegistryString(const char*, const char*, char*, size_t) {
335 // Get Visual Studio installation directory.
336 static bool getVisualStudioDir(std::string &path) {
337 // First check the environment variables that vsvars32.bat sets.
338 const char* vcinstalldir = getenv("VCINSTALLDIR");
340 char *p = const_cast<char *>(strstr(vcinstalldir, "\\VC"));
347 char vsIDEInstallDir[256];
348 char vsExpressIDEInstallDir[256];
349 // Then try the windows registry.
350 bool hasVCDir = getSystemRegistryString(
351 "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\$VERSION",
352 "InstallDir", vsIDEInstallDir, sizeof(vsIDEInstallDir) - 1);
353 bool hasVCExpressDir = getSystemRegistryString(
354 "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\$VERSION",
355 "InstallDir", vsExpressIDEInstallDir, sizeof(vsExpressIDEInstallDir) - 1);
356 // If we have both vc80 and vc90, pick version we were compiled with.
357 if (hasVCDir && vsIDEInstallDir[0]) {
358 char *p = (char*)strstr(vsIDEInstallDir, "\\Common7\\IDE");
361 path = vsIDEInstallDir;
365 if (hasVCExpressDir && vsExpressIDEInstallDir[0]) {
366 char *p = (char*)strstr(vsExpressIDEInstallDir, "\\Common7\\IDE");
369 path = vsExpressIDEInstallDir;
373 // Try the environment.
374 const char *vs100comntools = getenv("VS100COMNTOOLS");
375 const char *vs90comntools = getenv("VS90COMNTOOLS");
376 const char *vs80comntools = getenv("VS80COMNTOOLS");
377 const char *vscomntools = NULL;
379 // Try to find the version that we were compiled with
381 #if (_MSC_VER >= 1600) // VC100
382 else if(vs100comntools) {
383 vscomntools = vs100comntools;
385 #elif (_MSC_VER == 1500) // VC80
386 else if(vs90comntools) {
387 vscomntools = vs90comntools;
389 #elif (_MSC_VER == 1400) // VC80
390 else if(vs80comntools) {
391 vscomntools = vs80comntools;
394 // Otherwise find any version we can
395 else if (vs100comntools)
396 vscomntools = vs100comntools;
397 else if (vs90comntools)
398 vscomntools = vs90comntools;
399 else if (vs80comntools)
400 vscomntools = vs80comntools;
402 if (vscomntools && *vscomntools) {
403 const char *p = strstr(vscomntools, "\\Common7\\Tools");
404 path = p ? std::string(vscomntools, p) : vscomntools;
410 // Get Windows SDK installation directory.
411 static bool getWindowsSDKDir(std::string &path) {
412 char windowsSDKInstallDir[256];
413 // Try the Windows registry.
414 bool hasSDKDir = getSystemRegistryString(
415 "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\$VERSION",
416 "InstallationFolder",
417 windowsSDKInstallDir,
418 sizeof(windowsSDKInstallDir) - 1);
419 // If we have both vc80 and vc90, pick version we were compiled with.
420 if (hasSDKDir && windowsSDKInstallDir[0]) {
421 path = windowsSDKInstallDir;
427 void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
428 const HeaderSearchOptions &HSOpts) {
429 llvm::Triple::OSType os = triple.getOS();
431 if (HSOpts.UseStandardSystemIncludes) {
433 case llvm::Triple::FreeBSD:
434 case llvm::Triple::NetBSD:
437 // FIXME: temporary hack: hard-coded paths.
438 AddPath("/usr/local/include", System, true, false, false);
443 // Builtin includes use #include_next directives and should be positioned
444 // just prior C include dirs.
445 if (HSOpts.UseBuiltinIncludes) {
446 // Ignore the sys root, we *always* look for clang headers relative to
448 llvm::sys::Path P(HSOpts.ResourceDir);
449 P.appendComponent("include");
450 AddPath(P.str(), System, false, false, false, /*IgnoreSysRoot=*/ true);
453 // All remaining additions are for system include directories, early exit if
454 // we aren't using them.
455 if (!HSOpts.UseStandardSystemIncludes)
458 // Add dirs specified via 'configure --with-c-include-dirs'.
459 StringRef CIncludeDirs(C_INCLUDE_DIRS);
460 if (CIncludeDirs != "") {
461 SmallVector<StringRef, 5> dirs;
462 CIncludeDirs.split(dirs, ":");
463 for (SmallVectorImpl<StringRef>::iterator i = dirs.begin();
466 AddPath(*i, System, false, false, false);
471 case llvm::Triple::Win32: {
473 std::string WindowsSDKDir;
474 if (getVisualStudioDir(VSDir)) {
475 AddPath(VSDir + "\\VC\\include", System, false, false, false);
476 if (getWindowsSDKDir(WindowsSDKDir))
477 AddPath(WindowsSDKDir + "\\include", System, false, false, false);
479 AddPath(VSDir + "\\VC\\PlatformSDK\\Include",
480 System, false, false, false);
482 // Default install paths.
483 AddPath("C:/Program Files/Microsoft Visual Studio 10.0/VC/include",
484 System, false, false, false);
485 AddPath("C:/Program Files/Microsoft Visual Studio 9.0/VC/include",
486 System, false, false, false);
488 "C:/Program Files/Microsoft Visual Studio 9.0/VC/PlatformSDK/Include",
489 System, false, false, false);
490 AddPath("C:/Program Files/Microsoft Visual Studio 8/VC/include",
491 System, false, false, false);
493 "C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/Include",
494 System, false, false, false);
498 case llvm::Triple::Haiku:
499 AddPath("/boot/common/include", System, true, false, false);
500 AddPath("/boot/develop/headers/os", System, true, false, false);
501 AddPath("/boot/develop/headers/os/app", System, true, false, false);
502 AddPath("/boot/develop/headers/os/arch", System, true, false, false);
503 AddPath("/boot/develop/headers/os/device", System, true, false, false);
504 AddPath("/boot/develop/headers/os/drivers", System, true, false, false);
505 AddPath("/boot/develop/headers/os/game", System, true, false, false);
506 AddPath("/boot/develop/headers/os/interface", System, true, false, false);
507 AddPath("/boot/develop/headers/os/kernel", System, true, false, false);
508 AddPath("/boot/develop/headers/os/locale", System, true, false, false);
509 AddPath("/boot/develop/headers/os/mail", System, true, false, false);
510 AddPath("/boot/develop/headers/os/media", System, true, false, false);
511 AddPath("/boot/develop/headers/os/midi", System, true, false, false);
512 AddPath("/boot/develop/headers/os/midi2", System, true, false, false);
513 AddPath("/boot/develop/headers/os/net", System, true, false, false);
514 AddPath("/boot/develop/headers/os/storage", System, true, false, false);
515 AddPath("/boot/develop/headers/os/support", System, true, false, false);
516 AddPath("/boot/develop/headers/os/translation",
517 System, true, false, false);
518 AddPath("/boot/develop/headers/os/add-ons/graphics",
519 System, true, false, false);
520 AddPath("/boot/develop/headers/os/add-ons/input_server",
521 System, true, false, false);
522 AddPath("/boot/develop/headers/os/add-ons/screen_saver",
523 System, true, false, false);
524 AddPath("/boot/develop/headers/os/add-ons/tracker",
525 System, true, false, false);
526 AddPath("/boot/develop/headers/os/be_apps/Deskbar",
527 System, true, false, false);
528 AddPath("/boot/develop/headers/os/be_apps/NetPositive",
529 System, true, false, false);
530 AddPath("/boot/develop/headers/os/be_apps/Tracker",
531 System, true, false, false);
532 AddPath("/boot/develop/headers/cpp", System, true, false, false);
533 AddPath("/boot/develop/headers/cpp/i586-pc-haiku",
534 System, true, false, false);
535 AddPath("/boot/develop/headers/3rdparty", System, true, false, false);
536 AddPath("/boot/develop/headers/bsd", System, true, false, false);
537 AddPath("/boot/develop/headers/glibc", System, true, false, false);
538 AddPath("/boot/develop/headers/posix", System, true, false, false);
539 AddPath("/boot/develop/headers", System, true, false, false);
541 case llvm::Triple::RTEMS:
543 case llvm::Triple::Cygwin:
544 AddPath("/usr/include/w32api", System, true, false, false);
546 case llvm::Triple::MinGW32: {
547 // mingw-w64 crt include paths
548 llvm::sys::Path P(HSOpts.ResourceDir);
549 P.appendComponent("../../../i686-w64-mingw32/include"); // <sysroot>/i686-w64-mingw32/include
550 AddPath(P.str(), System, true, false, false);
551 P = llvm::sys::Path(HSOpts.ResourceDir);
552 P.appendComponent("../../../x86_64-w64-mingw32/include"); // <sysroot>/x86_64-w64-mingw32/include
553 AddPath(P.str(), System, true, false, false);
554 // mingw.org crt include paths
555 P = llvm::sys::Path(HSOpts.ResourceDir);
556 P.appendComponent("../../../include"); // <sysroot>/include
557 AddPath(P.str(), System, true, false, false);
558 AddPath("/mingw/include", System, true, false, false);
559 AddPath("c:/mingw/include", System, true, false, false);
562 case llvm::Triple::FreeBSD:
563 AddPath(CLANG_PREFIX "/usr/include/clang/" CLANG_VERSION_STRING,
564 System, false, false, false);
567 case llvm::Triple::Linux:
568 // Generic Debian multiarch support:
569 if (triple.getArch() == llvm::Triple::x86_64) {
570 AddPath("/usr/include/x86_64-linux-gnu", System, false, false, false);
571 AddPath("/usr/include/i686-linux-gnu/64", System, false, false, false);
572 AddPath("/usr/include/i486-linux-gnu/64", System, false, false, false);
573 } else if (triple.getArch() == llvm::Triple::x86) {
574 AddPath("/usr/include/x86_64-linux-gnu/32", System, false, false, false);
575 AddPath("/usr/include/i686-linux-gnu", System, false, false, false);
576 AddPath("/usr/include/i486-linux-gnu", System, false, false, false);
577 } else if (triple.getArch() == llvm::Triple::arm) {
578 AddPath("/usr/include/arm-linux-gnueabi", System, false, false, false);
584 if ( os != llvm::Triple::RTEMS )
585 AddPath(CLANG_PREFIX "/usr/include", System, false, false, false);
588 void InitHeaderSearch::
589 AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple, const HeaderSearchOptions &HSOpts) {
590 llvm::Triple::OSType os = triple.getOS();
591 StringRef CxxIncludeRoot(CXX_INCLUDE_ROOT);
592 if (CxxIncludeRoot != "") {
593 StringRef CxxIncludeArch(CXX_INCLUDE_ARCH);
594 if (CxxIncludeArch == "")
595 AddGnuCPlusPlusIncludePaths(CxxIncludeRoot, triple.str().c_str(),
596 CXX_INCLUDE_32BIT_DIR, CXX_INCLUDE_64BIT_DIR,
599 AddGnuCPlusPlusIncludePaths(CxxIncludeRoot, CXX_INCLUDE_ARCH,
600 CXX_INCLUDE_32BIT_DIR, CXX_INCLUDE_64BIT_DIR,
604 // FIXME: temporary hack: hard-coded paths.
606 if (triple.isOSDarwin()) {
607 switch (triple.getArch()) {
610 case llvm::Triple::ppc:
611 case llvm::Triple::ppc64:
612 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
613 "powerpc-apple-darwin10", "", "ppc64",
615 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.0.0",
616 "powerpc-apple-darwin10", "", "ppc64",
620 case llvm::Triple::x86:
621 case llvm::Triple::x86_64:
622 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
623 "i686-apple-darwin10", "", "x86_64", triple);
624 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.0.0",
625 "i686-apple-darwin8", "", "", triple);
628 case llvm::Triple::arm:
629 case llvm::Triple::thumb:
630 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
631 "arm-apple-darwin10", "v7", "", triple);
632 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
633 "arm-apple-darwin10", "v6", "", triple);
640 case llvm::Triple::Cygwin:
642 AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "4.3.4");
643 // g++-4 / Cygwin-1.5
644 AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "4.3.2");
645 // FIXME: Do we support g++-3.4.4?
646 AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "3.4.4");
648 case llvm::Triple::MinGW32:
649 // mingw-w64 C++ include paths (i686-w64-mingw32 and x86_64-w64-mingw32)
650 AddMinGW64CXXPaths(HSOpts.ResourceDir, "4.5.0");
651 AddMinGW64CXXPaths(HSOpts.ResourceDir, "4.5.1");
652 AddMinGW64CXXPaths(HSOpts.ResourceDir, "4.5.2");
653 AddMinGW64CXXPaths(HSOpts.ResourceDir, "4.5.3");
654 AddMinGW64CXXPaths(HSOpts.ResourceDir, "4.6.0");
655 AddMinGW64CXXPaths(HSOpts.ResourceDir, "4.6.1");
656 AddMinGW64CXXPaths(HSOpts.ResourceDir, "4.6.2");
657 AddMinGW64CXXPaths(HSOpts.ResourceDir, "4.7.0");
658 // mingw.org C++ include paths
659 AddMinGWCPlusPlusIncludePaths("/mingw/lib/gcc", "mingw32", "4.5.2"); //MSYS
660 AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", "mingw32", "4.5.0");
661 AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", "mingw32", "4.4.0");
662 AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", "mingw32", "4.3.0");
664 case llvm::Triple::DragonFly:
665 AddPath("/usr/include/c++/4.1", CXXSystem, true, false, false);
667 case llvm::Triple::Linux:
668 //===------------------------------------------------------------------===//
669 // Debian based distros.
670 // Note: these distros symlink /usr/include/c++/X.Y.Z -> X.Y
671 //===------------------------------------------------------------------===//
673 // Ubuntu 11.11 "Oneiric Ocelot" -- gcc-4.6.0
674 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6",
675 "x86_64-linux-gnu", "32", "", triple);
676 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6",
677 "i686-linux-gnu", "", "64", triple);
678 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6",
679 "i486-linux-gnu", "", "64", triple);
680 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6",
681 "arm-linux-gnueabi", "", "", triple);
683 // Ubuntu 11.04 "Natty Narwhal" -- gcc-4.5.2
684 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5",
685 "x86_64-linux-gnu", "32", "", triple);
686 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5",
687 "i686-linux-gnu", "", "64", triple);
688 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5",
689 "i486-linux-gnu", "", "64", triple);
690 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5",
691 "arm-linux-gnueabi", "", "", triple);
693 // Ubuntu 10.10 "Maverick Meerkat" -- gcc-4.4.5
694 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4",
695 "i686-linux-gnu", "", "64", triple);
696 // The rest of 10.10 is the same as previous versions.
698 // Ubuntu 10.04 LTS "Lucid Lynx" -- gcc-4.4.3
699 // Ubuntu 9.10 "Karmic Koala" -- gcc-4.4.1
700 // Debian 6.0 "squeeze" -- gcc-4.4.2
701 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4",
702 "x86_64-linux-gnu", "32", "", triple);
703 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4",
704 "i486-linux-gnu", "", "64", triple);
705 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4",
706 "arm-linux-gnueabi", "", "", triple);
707 // Ubuntu 9.04 "Jaunty Jackalope" -- gcc-4.3.3
708 // Ubuntu 8.10 "Intrepid Ibex" -- gcc-4.3.2
709 // Debian 5.0 "lenny" -- gcc-4.3.2
710 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3",
711 "x86_64-linux-gnu", "32", "", triple);
712 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3",
713 "i486-linux-gnu", "", "64", triple);
714 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3",
715 "arm-linux-gnueabi", "", "", triple);
716 // Ubuntu 8.04.4 LTS "Hardy Heron" -- gcc-4.2.4
717 // Ubuntu 8.04.[0-3] LTS "Hardy Heron" -- gcc-4.2.3
718 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2",
719 "x86_64-linux-gnu", "32", "", triple);
720 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2",
721 "i486-linux-gnu", "", "64", triple);
722 // Ubuntu 7.10 "Gutsy Gibbon" -- gcc-4.1.3
723 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1",
724 "x86_64-linux-gnu", "32", "", triple);
725 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1",
726 "i486-linux-gnu", "", "64", triple);
728 //===------------------------------------------------------------------===//
729 // Redhat based distros.
730 //===------------------------------------------------------------------===//
731 // Fedora 15 (GCC 4.6.1)
732 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.1",
733 "x86_64-redhat-linux", "32", "", triple);
734 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.1",
735 "i686-redhat-linux", "", "", triple);
736 // Fedora 15 (GCC 4.6.0)
737 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.0",
738 "x86_64-redhat-linux", "32", "", triple);
739 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.0",
740 "i686-redhat-linux", "", "", triple);
742 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5.1",
743 "x86_64-redhat-linux", "32", "", triple);
744 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5.1",
745 "i686-redhat-linux", "", "", triple);
747 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.4",
748 "x86_64-redhat-linux6E", "32", "", triple);
750 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.4",
751 "x86_64-redhat-linux", "32", "", triple);
752 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.4",
753 "i686-redhat-linux","", "", triple);
755 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.3",
756 "x86_64-redhat-linux", "32", "", triple);
757 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.3",
758 "i686-redhat-linux","", "", triple);
759 // Fedora 12 (pre-FEB-2010)
760 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.2",
761 "x86_64-redhat-linux", "32", "", triple);
762 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.2",
763 "i686-redhat-linux","", "", triple);
765 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.1",
766 "x86_64-redhat-linux", "32", "", triple);
767 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.1",
768 "i586-redhat-linux","", "", triple);
770 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.2",
771 "x86_64-redhat-linux", "32", "", triple);
772 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.2",
773 "i386-redhat-linux","", "", triple);
775 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.0",
776 "x86_64-redhat-linux", "32", "", triple);
777 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.0",
778 "i386-redhat-linux", "", "", triple);
780 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1.2",
781 "x86_64-redhat-linux", "", "", triple);
782 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1.2",
783 "i386-redhat-linux", "", "", triple);
786 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1.1",
787 "x86_64-redhat-linux", "32", "", triple);
788 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1.1",
789 "i386-redhat-linux", "", "", triple);
792 //===------------------------------------------------------------------===//
794 // Exherbo (2010-01-25)
795 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.3",
796 "x86_64-pc-linux-gnu", "32", "", triple);
797 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.3",
798 "i686-pc-linux-gnu", "", "", triple);
800 // openSUSE 11.1 32 bit
801 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3",
802 "i586-suse-linux", "", "", triple);
803 // openSUSE 11.1 64 bit
804 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3",
805 "x86_64-suse-linux", "32", "", triple);
807 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4",
808 "i586-suse-linux", "", "", triple);
809 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4",
810 "x86_64-suse-linux", "", "", triple);
813 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5",
814 "i586-suse-linux", "", "", triple);
815 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5",
816 "x86_64-suse-linux", "", "", triple);
819 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6",
820 "i586-suse-linux", "", "", triple);
821 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6",
822 "x86_64-suse-linux", "", "", triple);
823 // Arch Linux 2008-06-24
824 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.1",
825 "i686-pc-linux-gnu", "", "", triple);
826 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.1",
827 "x86_64-unknown-linux-gnu", "", "", triple);
829 // Arch Linux gcc 4.6
830 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.1",
831 "i686-pc-linux-gnu", "", "", triple);
832 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.1",
833 "x86_64-unknown-linux-gnu", "", "", triple);
834 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.0",
835 "i686-pc-linux-gnu", "", "", triple);
836 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.0",
837 "x86_64-unknown-linux-gnu", "", "", triple);
839 // Slackware gcc 4.5.2 (13.37)
840 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5.2",
841 "i486-slackware-linux", "", "", triple);
842 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5.2",
843 "x86_64-slackware-linux", "", "", triple);
844 // Slackware gcc 4.5.3 (-current)
845 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5.3",
846 "i486-slackware-linux", "", "", triple);
847 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5.3",
848 "x86_64-slackware-linux", "", "", triple);
850 // Gentoo x86 gcc 4.5.2
851 AddGnuCPlusPlusIncludePaths(
852 "/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/g++-v4",
853 "i686-pc-linux-gnu", "", "", triple);
854 // Gentoo x86 gcc 4.4.5
855 AddGnuCPlusPlusIncludePaths(
856 "/usr/lib/gcc/i686-pc-linux-gnu/4.4.5/include/g++-v4",
857 "i686-pc-linux-gnu", "", "", triple);
858 // Gentoo x86 gcc 4.4.4
859 AddGnuCPlusPlusIncludePaths(
860 "/usr/lib/gcc/i686-pc-linux-gnu/4.4.4/include/g++-v4",
861 "i686-pc-linux-gnu", "", "", triple);
862 // Gentoo x86 2010.0 stable
863 AddGnuCPlusPlusIncludePaths(
864 "/usr/lib/gcc/i686-pc-linux-gnu/4.4.3/include/g++-v4",
865 "i686-pc-linux-gnu", "", "", triple);
866 // Gentoo x86 2009.1 stable
867 AddGnuCPlusPlusIncludePaths(
868 "/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4",
869 "i686-pc-linux-gnu", "", "", triple);
870 // Gentoo x86 2009.0 stable
871 AddGnuCPlusPlusIncludePaths(
872 "/usr/lib/gcc/i686-pc-linux-gnu/4.3.2/include/g++-v4",
873 "i686-pc-linux-gnu", "", "", triple);
874 // Gentoo x86 2008.0 stable
875 AddGnuCPlusPlusIncludePaths(
876 "/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4",
877 "i686-pc-linux-gnu", "", "", triple);
878 // Gentoo x86 llvm-gcc trunk
879 AddGnuCPlusPlusIncludePaths(
880 "/usr/lib/llvm-gcc-4.2-9999/include/c++/4.2.1",
881 "i686-pc-linux-gnu", "", "", triple);
883 // Gentoo amd64 gcc 4.5.2
884 AddGnuCPlusPlusIncludePaths(
885 "/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/include/g++-v4",
886 "x86_64-pc-linux-gnu", "32", "", triple);
887 // Gentoo amd64 gcc 4.4.5
888 AddGnuCPlusPlusIncludePaths(
889 "/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.5/include/g++-v4",
890 "x86_64-pc-linux-gnu", "32", "", triple);
891 // Gentoo amd64 gcc 4.4.4
892 AddGnuCPlusPlusIncludePaths(
893 "/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.4/include/g++-v4",
894 "x86_64-pc-linux-gnu", "32", "", triple);
895 // Gentoo amd64 gcc 4.4.3
896 AddGnuCPlusPlusIncludePaths(
897 "/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.3/include/g++-v4",
898 "x86_64-pc-linux-gnu", "32", "", triple);
899 // Gentoo amd64 gcc 4.3.4
900 AddGnuCPlusPlusIncludePaths(
901 "/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.4/include/g++-v4",
902 "x86_64-pc-linux-gnu", "", "", triple);
903 // Gentoo amd64 gcc 4.3.2
904 AddGnuCPlusPlusIncludePaths(
905 "/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/include/g++-v4",
906 "x86_64-pc-linux-gnu", "", "", triple);
907 // Gentoo amd64 stable
908 AddGnuCPlusPlusIncludePaths(
909 "/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/include/g++-v4",
910 "x86_64-pc-linux-gnu", "", "", triple);
912 // Gentoo amd64 llvm-gcc trunk
913 AddGnuCPlusPlusIncludePaths(
914 "/usr/lib/llvm-gcc-4.2-9999/include/c++/4.2.1",
915 "x86_64-pc-linux-gnu", "", "", triple);
918 case llvm::Triple::FreeBSD:
921 AddGnuCPlusPlusIncludePaths(CLANG_PREFIX "/usr/include/c++/4.2",
923 AddGnuCPlusPlusIncludePaths(CLANG_PREFIX "/usr/include/c++/4.2/backward",
926 case llvm::Triple::NetBSD:
927 AddGnuCPlusPlusIncludePaths("/usr/include/g++", "", "", "", triple);
929 case llvm::Triple::OpenBSD: {
930 std::string t = triple.getTriple();
931 if (t.substr(0, 6) == "x86_64")
932 t.replace(0, 6, "amd64");
933 AddGnuCPlusPlusIncludePaths("/usr/include/g++",
937 case llvm::Triple::Minix:
938 AddGnuCPlusPlusIncludePaths("/usr/gnu/include/c++/4.4.3",
941 case llvm::Triple::Solaris:
942 // Solaris - Fall though..
943 case llvm::Triple::AuroraUX:
945 AddGnuCPlusPlusIncludePaths("/opt/gcc4/include/c++/4.2.4",
946 "i386-pc-solaris2.11", "", "", triple);
953 void InitHeaderSearch::AddDefaultIncludePaths(const LangOptions &Lang,
954 const llvm::Triple &triple,
955 const HeaderSearchOptions &HSOpts) {
956 if (Lang.CPlusPlus && HSOpts.UseStandardCXXIncludes &&
957 HSOpts.UseStandardSystemIncludes) {
958 if (HSOpts.UseLibcxx) {
959 if (triple.isOSDarwin()) {
960 // On Darwin, libc++ may be installed alongside the compiler in
962 llvm::sys::Path P(HSOpts.ResourceDir);
964 P.eraseComponent(); // Remove version from foo/lib/clang/version
965 P.eraseComponent(); // Remove clang from foo/lib/clang
967 // Get foo/lib/c++/v1
968 P.appendComponent("c++");
969 P.appendComponent("v1");
970 AddPath(P.str(), CXXSystem, true, false, false, true);
974 AddPath("/usr/include/c++/v1", CXXSystem, true, false, false);
976 AddDefaultCPlusPlusIncludePaths(triple, HSOpts);
980 AddDefaultCIncludePaths(triple, HSOpts);
982 // Add the default framework include paths on Darwin.
983 if (HSOpts.UseStandardSystemIncludes) {
984 if (triple.isOSDarwin()) {
985 AddPath("/System/Library/Frameworks", System, true, false, true);
986 AddPath("/Library/Frameworks", System, true, false, true);
991 /// RemoveDuplicates - If there are duplicate directory entries in the specified
992 /// search list, remove the later (dead) ones. Returns the number of non-system
993 /// headers removed, which is used to update NumAngled.
994 static unsigned RemoveDuplicates(std::vector<DirectoryLookup> &SearchList,
995 unsigned First, bool Verbose) {
996 llvm::SmallPtrSet<const DirectoryEntry *, 8> SeenDirs;
997 llvm::SmallPtrSet<const DirectoryEntry *, 8> SeenFrameworkDirs;
998 llvm::SmallPtrSet<const HeaderMap *, 8> SeenHeaderMaps;
999 unsigned NonSystemRemoved = 0;
1000 for (unsigned i = First; i != SearchList.size(); ++i) {
1001 unsigned DirToRemove = i;
1003 const DirectoryLookup &CurEntry = SearchList[i];
1005 if (CurEntry.isNormalDir()) {
1006 // If this isn't the first time we've seen this dir, remove it.
1007 if (SeenDirs.insert(CurEntry.getDir()))
1009 } else if (CurEntry.isFramework()) {
1010 // If this isn't the first time we've seen this framework dir, remove it.
1011 if (SeenFrameworkDirs.insert(CurEntry.getFrameworkDir()))
1014 assert(CurEntry.isHeaderMap() && "Not a headermap or normal dir?");
1015 // If this isn't the first time we've seen this headermap, remove it.
1016 if (SeenHeaderMaps.insert(CurEntry.getHeaderMap()))
1020 // If we have a normal #include dir/framework/headermap that is shadowed
1021 // later in the chain by a system include location, we actually want to
1022 // ignore the user's request and drop the user dir... keeping the system
1023 // dir. This is weird, but required to emulate GCC's search path correctly.
1025 // Since dupes of system dirs are rare, just rescan to find the original
1026 // that we're nuking instead of using a DenseMap.
1027 if (CurEntry.getDirCharacteristic() != SrcMgr::C_User) {
1028 // Find the dir that this is the same of.
1030 for (FirstDir = 0; ; ++FirstDir) {
1031 assert(FirstDir != i && "Didn't find dupe?");
1033 const DirectoryLookup &SearchEntry = SearchList[FirstDir];
1035 // If these are different lookup types, then they can't be the dupe.
1036 if (SearchEntry.getLookupType() != CurEntry.getLookupType())
1040 if (CurEntry.isNormalDir())
1041 isSame = SearchEntry.getDir() == CurEntry.getDir();
1042 else if (CurEntry.isFramework())
1043 isSame = SearchEntry.getFrameworkDir() == CurEntry.getFrameworkDir();
1045 assert(CurEntry.isHeaderMap() && "Not a headermap or normal dir?");
1046 isSame = SearchEntry.getHeaderMap() == CurEntry.getHeaderMap();
1053 // If the first dir in the search path is a non-system dir, zap it
1054 // instead of the system one.
1055 if (SearchList[FirstDir].getDirCharacteristic() == SrcMgr::C_User)
1056 DirToRemove = FirstDir;
1060 llvm::errs() << "ignoring duplicate directory \""
1061 << CurEntry.getName() << "\"\n";
1062 if (DirToRemove != i)
1063 llvm::errs() << " as it is a non-system directory that duplicates "
1064 << "a system directory\n";
1066 if (DirToRemove != i)
1069 // This is reached if the current entry is a duplicate. Remove the
1070 // DirToRemove (usually the current dir).
1071 SearchList.erase(SearchList.begin()+DirToRemove);
1074 return NonSystemRemoved;
1078 void InitHeaderSearch::Realize(const LangOptions &Lang) {
1079 // Concatenate ANGLE+SYSTEM+AFTER chains together into SearchList.
1080 std::vector<DirectoryLookup> SearchList;
1081 SearchList.reserve(IncludePath.size());
1083 // Quoted arguments go first.
1084 for (path_iterator it = IncludePath.begin(), ie = IncludePath.end();
1086 if (it->first == Quoted)
1087 SearchList.push_back(it->second);
1089 // Deduplicate and remember index.
1090 RemoveDuplicates(SearchList, 0, Verbose);
1091 unsigned NumQuoted = SearchList.size();
1093 for (path_iterator it = IncludePath.begin(), ie = IncludePath.end();
1095 if (it->first == Angled || it->first == IndexHeaderMap)
1096 SearchList.push_back(it->second);
1099 RemoveDuplicates(SearchList, NumQuoted, Verbose);
1100 unsigned NumAngled = SearchList.size();
1102 for (path_iterator it = IncludePath.begin(), ie = IncludePath.end();
1104 if (it->first == System ||
1105 (!Lang.ObjC1 && !Lang.CPlusPlus && it->first == CSystem) ||
1106 (/*FIXME !Lang.ObjC1 && */Lang.CPlusPlus && it->first == CXXSystem) ||
1107 (Lang.ObjC1 && !Lang.CPlusPlus && it->first == ObjCSystem) ||
1108 (Lang.ObjC1 && Lang.CPlusPlus && it->first == ObjCXXSystem))
1109 SearchList.push_back(it->second);
1112 for (path_iterator it = IncludePath.begin(), ie = IncludePath.end();
1114 if (it->first == After)
1115 SearchList.push_back(it->second);
1118 // Remove duplicates across both the Angled and System directories. GCC does
1119 // this and failing to remove duplicates across these two groups breaks
1121 unsigned NonSystemRemoved = RemoveDuplicates(SearchList, NumQuoted, Verbose);
1122 NumAngled -= NonSystemRemoved;
1124 bool DontSearchCurDir = false; // TODO: set to true if -I- is set?
1125 Headers.SetSearchPaths(SearchList, NumQuoted, NumAngled, DontSearchCurDir);
1127 // If verbose, print the list of directories that will be searched.
1129 llvm::errs() << "#include \"...\" search starts here:\n";
1130 for (unsigned i = 0, e = SearchList.size(); i != e; ++i) {
1132 llvm::errs() << "#include <...> search starts here:\n";
1133 const char *Name = SearchList[i].getName();
1135 if (SearchList[i].isNormalDir())
1137 else if (SearchList[i].isFramework())
1138 Suffix = " (framework directory)";
1140 assert(SearchList[i].isHeaderMap() && "Unknown DirectoryLookup");
1141 Suffix = " (headermap)";
1143 llvm::errs() << " " << Name << Suffix << "\n";
1145 llvm::errs() << "End of search list.\n";
1149 void clang::ApplyHeaderSearchOptions(HeaderSearch &HS,
1150 const HeaderSearchOptions &HSOpts,
1151 const LangOptions &Lang,
1152 const llvm::Triple &Triple) {
1153 InitHeaderSearch Init(HS, HSOpts.Verbose, HSOpts.Sysroot);
1155 // Add the user defined entries.
1156 for (unsigned i = 0, e = HSOpts.UserEntries.size(); i != e; ++i) {
1157 const HeaderSearchOptions::Entry &E = HSOpts.UserEntries[i];
1158 Init.AddPath(E.Path, E.Group, false, E.IsUserSupplied, E.IsFramework,
1162 Init.AddDefaultIncludePaths(Lang, Triple, HSOpts);