InitHeaderSearch.cpp revision 236a537eacbb347b5aa19a8aa2c82cdb7da8a62b
1df22c2cc7703c7df04eadd2e6e59c61f545a5741Nick Lewycky//===--- InitHeaderSearch.cpp - Initialize header search paths ------------===// 20fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber// 30fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber// The LLVM Compiler Infrastructure 40fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber// 50fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber// This file is distributed under the University of Illinois Open Source 60fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber// License. See LICENSE.TXT for details. 70fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber// 80fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber//===----------------------------------------------------------------------===// 90fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber// 100fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber// This file implements the InitHeaderSearch class. 110fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber// 120fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber//===----------------------------------------------------------------------===// 130fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber 142100fe952a644134b1dca462f2e6330cf14ef47cOscar Fuentes#ifdef HAVE_CLANG_CONFIG_H 152100fe952a644134b1dca462f2e6330cf14ef47cOscar Fuentes# include "clang/Config/config.h" 162100fe952a644134b1dca462f2e6330cf14ef47cOscar Fuentes#endif 172100fe952a644134b1dca462f2e6330cf14ef47cOscar Fuentes 182cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar#include "clang/Frontend/Utils.h" 190fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber#include "clang/Basic/FileManager.h" 200fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber#include "clang/Basic/LangOptions.h" 2163c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar#include "clang/Frontend/HeaderSearchOptions.h" 2263c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar#include "clang/Lex/HeaderSearch.h" 230fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber#include "llvm/ADT/SmallString.h" 240fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber#include "llvm/ADT/SmallPtrSet.h" 25aadd7a48453b4f58bd8e1e9eb670918ee7d6a711Rafael Espindola#include "llvm/ADT/SmallVector.h" 26f0a2f51be576089e1a84cd677c09156dae067b6aRafael Espindola#include "llvm/ADT/StringExtras.h" 272cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar#include "llvm/ADT/Triple.h" 28e89ba59005479529f5567f12b436617a2ca73ec2Benjamin Kramer#include "llvm/ADT/Twine.h" 29d57a7ef9252964bc6c8471451d7bd395b0520cb8Chris Lattner#include "llvm/Support/raw_ostream.h" 3003013fa9a0bf1ef4b907f5fec006c8f4000fdd21Michael J. Spencer#include "llvm/Support/Path.h" 31121e3c207415fb4c105d690de384d8f3d49b0f2dArgyrios Kyrtzidis#include "llvm/Config/config.h" 32620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump#ifdef _MSC_VER 33620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump #define WIN32_LEAN_AND_MEAN 1 34620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump #include <windows.h> 35620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump#endif 360fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weberusing namespace clang; 372cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbarusing namespace clang::frontend; 382cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar 392cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbarnamespace { 402cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar 412cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar/// InitHeaderSearch - This class makes it easier to set the search paths of 422cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar/// a HeaderSearch object. InitHeaderSearch stores several search path lists 432cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar/// internally, which can be sent to a HeaderSearch object in one swoop. 442cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbarclass InitHeaderSearch { 452df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger std::vector<std::pair<IncludeDirGroup, DirectoryLookup> > IncludePath; 462df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger typedef std::vector<std::pair<IncludeDirGroup, 472df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger DirectoryLookup> >::const_iterator path_iterator; 48ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner HeaderSearch &Headers; 492cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar bool Verbose; 50af6530c938bfc60902f0dfec1c0808aedbee1663Michael J. Spencer std::string IncludeSysroot; 51af6530c938bfc60902f0dfec1c0808aedbee1663Michael J. Spencer bool IsNotEmptyOrRoot; 522cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar 532cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbarpublic: 542cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar 555f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner InitHeaderSearch(HeaderSearch &HS, bool verbose, StringRef sysroot) 56af6530c938bfc60902f0dfec1c0808aedbee1663Michael J. Spencer : Headers(HS), Verbose(verbose), IncludeSysroot(sysroot), 57af6530c938bfc60902f0dfec1c0808aedbee1663Michael J. Spencer IsNotEmptyOrRoot(!(sysroot.empty() || sysroot == "/")) { 58c09265a5fd94af5dcfd7325d0cb4f04197d65afcChandler Carruth } 592cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar 602cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar /// AddPath - Add the specified path to the specified group list. 615f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner void AddPath(const Twine &Path, IncludeDirGroup Group, 622cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar bool isCXXAware, bool isUserSupplied, 632cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar bool isFramework, bool IgnoreSysRoot = false); 642cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar 65a608737659d4330d9ae7622bf1a87c33b9d97072mike-m /// AddGnuCPlusPlusIncludePaths - Add the necessary paths to support a gnu 662cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar /// libstdc++. 675f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner void AddGnuCPlusPlusIncludePaths(StringRef Base, 685f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner StringRef ArchDir, 695f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner StringRef Dir32, 705f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner StringRef Dir64, 712cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar const llvm::Triple &triple); 722cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar 7306a8dc616ec8324694d45cd4d724634a899be9a3Michael J. Spencer /// AddMinGWCPlusPlusIncludePaths - Add the necessary paths to support a MinGW 742cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar /// libstdc++. 755f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner void AddMinGWCPlusPlusIncludePaths(StringRef Base, 765f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner StringRef Arch, 775f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner StringRef Version); 782cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar 799db48467f19d4f0929a5ba40c5e2bd7255dc95f0NAKAMURA Takumi /// AddMinGW64CXXPaths - Add the necessary paths to support 809db48467f19d4f0929a5ba40c5e2bd7255dc95f0NAKAMURA Takumi /// libstdc++ of x86_64-w64-mingw32 aka mingw-w64. 815f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner void AddMinGW64CXXPaths(StringRef Base, 825f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner StringRef Version); 839db48467f19d4f0929a5ba40c5e2bd7255dc95f0NAKAMURA Takumi 842cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar /// AddDelimitedPaths - Add a list of paths delimited by the system PATH 852cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar /// separator. The processing follows that of the CPATH variable for gcc. 865f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner void AddDelimitedPaths(StringRef String); 872cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar 882cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar // AddDefaultCIncludePaths - Add paths that should always be searched. 8979bc57c074cb91f574fba19215f95b63dcf6b04bmike-m void AddDefaultCIncludePaths(const llvm::Triple &triple, 9079bc57c074cb91f574fba19215f95b63dcf6b04bmike-m const HeaderSearchOptions &HSOpts); 912cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar 922cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar // AddDefaultCPlusPlusIncludePaths - Add paths that should be searched when 932cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar // compiling c++. 94d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor void AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple, 95d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor const HeaderSearchOptions &HSOpts); 962cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar 972cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar /// AddDefaultSystemIncludePaths - Adds the default system include paths so 982cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar /// that e.g. stdio.h is found. 992cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar void AddDefaultSystemIncludePaths(const LangOptions &Lang, 1004c2bcad7b843c10fd4a2ffd43da40bfefb4dc8baDouglas Gregor const llvm::Triple &triple, 10179bc57c074cb91f574fba19215f95b63dcf6b04bmike-m const HeaderSearchOptions &HSOpts); 1022cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar 1032cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar /// Realize - Merges all search path lists into one list and send it to 1042cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar /// HeaderSearch. 1052df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger void Realize(const LangOptions &Lang); 1062cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar}; 1072cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar 108ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner} // end anonymous namespace. 1090fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber 1105f9e272e632e951b1efe824cd16acb4d96077930Chris Lattnervoid InitHeaderSearch::AddPath(const Twine &Path, 111458fb10ef5ba2d7b375c6c64095c1458af0a5be3Benjamin Kramer IncludeDirGroup Group, bool isCXXAware, 112458fb10ef5ba2d7b375c6c64095c1458af0a5be3Benjamin Kramer bool isUserSupplied, bool isFramework, 113458fb10ef5ba2d7b375c6c64095c1458af0a5be3Benjamin Kramer bool IgnoreSysRoot) { 114e89ba59005479529f5567f12b436617a2ca73ec2Benjamin Kramer assert(!Path.isTriviallyEmpty() && "can't handle empty path here"); 1150fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber FileManager &FM = Headers.getFileMgr(); 1161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1170fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // Compute the actual path, taking into consideration -isysroot. 1185853b0f117ee811388219bce738b24835b8d7fb2Chandler Carruth llvm::SmallString<256> MappedPathStorage; 1195f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner StringRef MappedPathStr = Path.toStringRef(MappedPathStorage); 1201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1210fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // Handle isysroot. 1229a7e09d82f739c8fd1b6c28787397d698515a871Rafael Espindola if ((Group == System || Group == CXXSystem) && !IgnoreSysRoot && 1230f0cdab31a4f71914b7f654501d69d96e9f378daNAKAMURA Takumi#if defined(_WIN32) 1240f0cdab31a4f71914b7f654501d69d96e9f378daNAKAMURA Takumi !MappedPathStr.empty() && 1250f0cdab31a4f71914b7f654501d69d96e9f378daNAKAMURA Takumi llvm::sys::path::is_separator(MappedPathStr[0]) && 1260f0cdab31a4f71914b7f654501d69d96e9f378daNAKAMURA Takumi#else 127256053b31e697fdf0cc48f17d621c82fc3b8dff0Michael J. Spencer llvm::sys::path::is_absolute(MappedPathStr) && 1280f0cdab31a4f71914b7f654501d69d96e9f378daNAKAMURA Takumi#endif 129af6530c938bfc60902f0dfec1c0808aedbee1663Michael J. Spencer IsNotEmptyOrRoot) { 1305619ae5d25dc77410a444c86606d4ec9bae8b921Chandler Carruth MappedPathStorage.clear(); 131c09265a5fd94af5dcfd7325d0cb4f04197d65afcChandler Carruth MappedPathStr = 132af6530c938bfc60902f0dfec1c0808aedbee1663Michael J. Spencer (IncludeSysroot + Path).toStringRef(MappedPathStorage); 1330fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 1341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1350fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // Compute the DirectoryLookup type. 1369d72851fec9e9c62570a027d42701562bbf29751Chris Lattner SrcMgr::CharacteristicKind Type; 13765e02fa80e1c185f18e5f81cefc30d75383a7301Douglas Gregor if (Group == Quoted || Group == Angled || Group == IndexHeaderMap) 1380b9e736308af5397f558ffc8e780c438c2fdb563Chris Lattner Type = SrcMgr::C_User; 1390fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber else if (isCXXAware) 1400b9e736308af5397f558ffc8e780c438c2fdb563Chris Lattner Type = SrcMgr::C_System; 1410fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber else 1420b9e736308af5397f558ffc8e780c438c2fdb563Chris Lattner Type = SrcMgr::C_ExternCSystem; 1431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1450fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // If the directory exists, add it. 14639b49bcaaddb1049234fca9500c0ac02c088e23dChris Lattner if (const DirectoryEntry *DE = FM.getDirectory(MappedPathStr)) { 1472df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger IncludePath.push_back(std::make_pair(Group, DirectoryLookup(DE, Type, 1482df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger isUserSupplied, isFramework))); 1490fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber return; 1500fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 1511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1520fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // Check to see if this is an apple-style headermap (which are not allowed to 1530fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // be frameworks). 1540fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber if (!isFramework) { 15539b49bcaaddb1049234fca9500c0ac02c088e23dChris Lattner if (const FileEntry *FE = FM.getFile(MappedPathStr)) { 1560fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber if (const HeaderMap *HM = Headers.CreateHeaderMap(FE)) { 1570fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // It is a headermap, add it to the search path. 1582df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger IncludePath.push_back(std::make_pair(Group, DirectoryLookup(HM, Type, 15965e02fa80e1c185f18e5f81cefc30d75383a7301Douglas Gregor isUserSupplied, Group == IndexHeaderMap))); 1600fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber return; 1610fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 1620fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 1630fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 1641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1650fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber if (Verbose) 166f3721457cd9f364f262e7a2d61edcdad05996e61Chandler Carruth llvm::errs() << "ignoring nonexistent directory \"" 167f3721457cd9f364f262e7a2d61edcdad05996e61Chandler Carruth << MappedPathStr << "\"\n"; 1680fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber} 1690fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber 1700fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber 1715f9e272e632e951b1efe824cd16acb4d96077930Chris Lattnervoid InitHeaderSearch::AddDelimitedPaths(StringRef at) { 1729e9ddf6100fd50ca2f9f9d0106b856e20b43300fBenjamin Kramer if (at.empty()) // Empty string should not add '.' path. 1730fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber return; 1740fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber 1755f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner StringRef::size_type delim; 1765f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner while ((delim = at.find(llvm::sys::PathSeparator)) != StringRef::npos) { 1779e9ddf6100fd50ca2f9f9d0106b856e20b43300fBenjamin Kramer if (delim == 0) 1780fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber AddPath(".", Angled, false, true, false); 1790fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber else 1809e9ddf6100fd50ca2f9f9d0106b856e20b43300fBenjamin Kramer AddPath(at.substr(0, delim), Angled, false, true, false); 1819e9ddf6100fd50ca2f9f9d0106b856e20b43300fBenjamin Kramer at = at.substr(delim + 1); 1820fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 1839e9ddf6100fd50ca2f9f9d0106b856e20b43300fBenjamin Kramer 1849e9ddf6100fd50ca2f9f9d0106b856e20b43300fBenjamin Kramer if (at.empty()) 1850fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber AddPath(".", Angled, false, true, false); 1860fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber else 1870fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber AddPath(at, Angled, false, true, false); 1880fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber} 1890fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber 1905f9e272e632e951b1efe824cd16acb4d96077930Chris Lattnervoid InitHeaderSearch::AddGnuCPlusPlusIncludePaths(StringRef Base, 1915f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner StringRef ArchDir, 1925f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner StringRef Dir32, 1935f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner StringRef Dir64, 19431b63beefa058aa42a12a1c2b72b43a4ba21f7f1Rafael Espindola const llvm::Triple &triple) { 1956ec18a3f86c702004af66cce6ff979999a736898Rafael Espindola // Add the base dir 1962df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger AddPath(Base, CXXSystem, true, false, false); 197ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola 198ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola // Add the multilib dirs 19931b63beefa058aa42a12a1c2b72b43a4ba21f7f1Rafael Espindola llvm::Triple::ArchType arch = triple.getArch(); 20031b63beefa058aa42a12a1c2b72b43a4ba21f7f1Rafael Espindola bool is64bit = arch == llvm::Triple::ppc64 || arch == llvm::Triple::x86_64; 20131b63beefa058aa42a12a1c2b72b43a4ba21f7f1Rafael Espindola if (is64bit) 2022df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger AddPath(Base + "/" + ArchDir + "/" + Dir64, CXXSystem, true, false, false); 20331b63beefa058aa42a12a1c2b72b43a4ba21f7f1Rafael Espindola else 2042df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger AddPath(Base + "/" + ArchDir + "/" + Dir32, CXXSystem, true, false, false); 2056ec18a3f86c702004af66cce6ff979999a736898Rafael Espindola 2066ec18a3f86c702004af66cce6ff979999a736898Rafael Espindola // Add the backward dir 2072df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger AddPath(Base + "/backward", CXXSystem, true, false, false); 2082e9f652d53346bf7e64c8a12a9ff06b004a3e489Rafael Espindola} 2090fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber 2105f9e272e632e951b1efe824cd16acb4d96077930Chris Lattnervoid InitHeaderSearch::AddMinGWCPlusPlusIncludePaths(StringRef Base, 2115f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner StringRef Arch, 2125f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner StringRef Version) { 213ab8ae19ea4285a15ca43123e8e218e401dc5cb5aBenjamin Kramer AddPath(Base + "/" + Arch + "/" + Version + "/include/c++", 2142df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger CXXSystem, true, false, false); 2158e9006bb31184a38b7c4c9d3d3040394652cbd9bChris Lattner AddPath(Base + "/" + Arch + "/" + Version + "/include/c++/" + Arch, 2162df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger CXXSystem, true, false, false); 217ab8ae19ea4285a15ca43123e8e218e401dc5cb5aBenjamin Kramer AddPath(Base + "/" + Arch + "/" + Version + "/include/c++/backward", 2182df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger CXXSystem, true, false, false); 219620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump} 22043d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump 2215f9e272e632e951b1efe824cd16acb4d96077930Chris Lattnervoid InitHeaderSearch::AddMinGW64CXXPaths(StringRef Base, 2225f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner StringRef Version) { 223d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor // Assumes Base is HeaderSearchOpts' ResourceDir 224d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddPath(Base + "/../../../include/c++/" + Version, 2259db48467f19d4f0929a5ba40c5e2bd7255dc95f0NAKAMURA Takumi CXXSystem, true, false, false); 226d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddPath(Base + "/../../../include/c++/" + Version + "/x86_64-w64-mingw32", 2279db48467f19d4f0929a5ba40c5e2bd7255dc95f0NAKAMURA Takumi CXXSystem, true, false, false); 228d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddPath(Base + "/../../../include/c++/" + Version + "/i686-w64-mingw32", 229d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor CXXSystem, true, false, false); 230d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddPath(Base + "/../../../include/c++/" + Version + "/backward", 2319db48467f19d4f0929a5ba40c5e2bd7255dc95f0NAKAMURA Takumi CXXSystem, true, false, false); 2329db48467f19d4f0929a5ba40c5e2bd7255dc95f0NAKAMURA Takumi} 2339db48467f19d4f0929a5ba40c5e2bd7255dc95f0NAKAMURA Takumi 234620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump // FIXME: This probably should goto to some platform utils place. 235620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump#ifdef _MSC_VER 23675ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson 237620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump // Read registry string. 23875ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // This also supports a means to look for high-versioned keys by use 23975ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // of a $VERSION placeholder in the key path. 24075ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // $VERSION in the key path is a placeholder for the version number, 24175ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // causing the highest value path to be searched for and used. 24275ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // I.e. "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\$VERSION". 24375ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // There can be additional characters in the component. Only the numberic 24475ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // characters are compared. 2456cd5216bb61e6165d8f6e8fb781d45c035bd4e00Benjamin Kramerstatic bool getSystemRegistryString(const char *keyPath, const char *valueName, 2466cd5216bb61e6165d8f6e8fb781d45c035bd4e00Benjamin Kramer char *value, size_t maxLength) { 24743d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump HKEY hRootKey = NULL; 24843d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump HKEY hKey = NULL; 24943d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump const char* subKey = NULL; 25043d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump DWORD valueType; 25143d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump DWORD valueSize = maxLength - 1; 25275ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson long lResult; 25343d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump bool returnValue = false; 254ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner 25543d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump if (strncmp(keyPath, "HKEY_CLASSES_ROOT\\", 18) == 0) { 25643d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump hRootKey = HKEY_CLASSES_ROOT; 25743d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump subKey = keyPath + 18; 258ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner } else if (strncmp(keyPath, "HKEY_USERS\\", 11) == 0) { 25943d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump hRootKey = HKEY_USERS; 26043d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump subKey = keyPath + 11; 261ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner } else if (strncmp(keyPath, "HKEY_LOCAL_MACHINE\\", 19) == 0) { 26243d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump hRootKey = HKEY_LOCAL_MACHINE; 26343d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump subKey = keyPath + 19; 264ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner } else if (strncmp(keyPath, "HKEY_CURRENT_USER\\", 18) == 0) { 26543d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump hRootKey = HKEY_CURRENT_USER; 26643d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump subKey = keyPath + 18; 26743d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump } 26843d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump else 269ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner return false; 270ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner 27175ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson const char *placeHolder = strstr(subKey, "$VERSION"); 27275ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson char bestName[256]; 27375ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson bestName[0] = '\0'; 27475ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // If we have a $VERSION placeholder, do the highest-version search. 27575ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson if (placeHolder) { 27675ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson const char *keyEnd = placeHolder - 1; 27775ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson const char *nextKey = placeHolder; 27875ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // Find end of previous key. 27975ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson while ((keyEnd > subKey) && (*keyEnd != '\\')) 28075ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson keyEnd--; 28175ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // Find end of key containing $VERSION. 28275ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson while (*nextKey && (*nextKey != '\\')) 28375ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson nextKey++; 28475ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson size_t partialKeyLength = keyEnd - subKey; 28575ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson char partialKey[256]; 28675ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson if (partialKeyLength > sizeof(partialKey)) 28775ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson partialKeyLength = sizeof(partialKey); 28875ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson strncpy(partialKey, subKey, partialKeyLength); 28975ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson partialKey[partialKeyLength] = '\0'; 29075ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson HKEY hTopKey = NULL; 29175ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson lResult = RegOpenKeyEx(hRootKey, partialKey, 0, KEY_READ, &hTopKey); 29275ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson if (lResult == ERROR_SUCCESS) { 29375ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson char keyName[256]; 29475ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson int bestIndex = -1; 29575ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson double bestValue = 0.0; 29675ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson DWORD index, size = sizeof(keyName) - 1; 29733cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes for (index = 0; RegEnumKeyEx(hTopKey, index, keyName, &size, NULL, 29833cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes NULL, NULL, NULL) == ERROR_SUCCESS; index++) { 29933cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes const char *sp = keyName; 30033cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes while (*sp && !isdigit(*sp)) 30133cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes sp++; 30233cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes if (!*sp) 30333cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes continue; 30433cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes const char *ep = sp + 1; 30533cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes while (*ep && (isdigit(*ep) || (*ep == '.'))) 30633cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes ep++; 30733cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes char numBuf[32]; 30833cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes strncpy(numBuf, sp, sizeof(numBuf) - 1); 30933cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes numBuf[sizeof(numBuf) - 1] = '\0'; 31033cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes double value = strtod(numBuf, NULL); 31133cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes if (value > bestValue) { 31233cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes bestIndex = (int)index; 31333cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes bestValue = value; 31433cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes strcpy(bestName, keyName); 31533cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes } 31675ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson size = sizeof(keyName) - 1; 31775ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson } 31875ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // If we found the highest versioned key, open the key and get the value. 31975ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson if (bestIndex != -1) { 32075ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // Append rest of key. 32175ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson strncat(bestName, nextKey, sizeof(bestName) - 1); 32275ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson bestName[sizeof(bestName) - 1] = '\0'; 32375ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // Open the chosen key path remainder. 32475ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson lResult = RegOpenKeyEx(hTopKey, bestName, 0, KEY_READ, &hKey); 32575ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson if (lResult == ERROR_SUCCESS) { 32675ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson lResult = RegQueryValueEx(hKey, valueName, NULL, &valueType, 32775ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson (LPBYTE)value, &valueSize); 32875ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson if (lResult == ERROR_SUCCESS) 32975ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson returnValue = true; 33075ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson RegCloseKey(hKey); 33175ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson } 33275ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson } 33375ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson RegCloseKey(hTopKey); 33475ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson } 33575ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson } 33675ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson else { 33775ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson lResult = RegOpenKeyEx(hRootKey, subKey, 0, KEY_READ, &hKey); 33875ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson if (lResult == ERROR_SUCCESS) { 33975ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson lResult = RegQueryValueEx(hKey, valueName, NULL, &valueType, 34075ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson (LPBYTE)value, &valueSize); 34175ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson if (lResult == ERROR_SUCCESS) 34275ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson returnValue = true; 34375ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson RegCloseKey(hKey); 34475ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson } 34543d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump } 346ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner return returnValue; 34743d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump} 348620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump#else // _MSC_VER 349620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump // Read registry string. 3506cd5216bb61e6165d8f6e8fb781d45c035bd4e00Benjamin Kramerstatic bool getSystemRegistryString(const char*, const char*, char*, size_t) { 351620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump return(false); 352620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump} 353620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump#endif // _MSC_VER 354121e3c207415fb4c105d690de384d8f3d49b0f2dArgyrios Kyrtzidis 35543d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump // Get Visual Studio installation directory. 3566cd5216bb61e6165d8f6e8fb781d45c035bd4e00Benjamin Kramerstatic bool getVisualStudioDir(std::string &path) { 357ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer // First check the environment variables that vsvars32.bat sets. 358ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer const char* vcinstalldir = getenv("VCINSTALLDIR"); 359ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner if (vcinstalldir) { 360ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer char *p = const_cast<char *>(strstr(vcinstalldir, "\\VC")); 361ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer if (p) 362ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer *p = '\0'; 363ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer path = vcinstalldir; 364ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner return true; 365ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer } 366ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer 36775ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson char vsIDEInstallDir[256]; 36880f93d9fe82ebe7e58913646248240de838283beDouglas Gregor char vsExpressIDEInstallDir[256]; 369ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer // Then try the windows registry. 37075ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson bool hasVCDir = getSystemRegistryString( 37175ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\$VERSION", 37275ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson "InstallDir", vsIDEInstallDir, sizeof(vsIDEInstallDir) - 1); 37380f93d9fe82ebe7e58913646248240de838283beDouglas Gregor bool hasVCExpressDir = getSystemRegistryString( 37480f93d9fe82ebe7e58913646248240de838283beDouglas Gregor "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\$VERSION", 37580f93d9fe82ebe7e58913646248240de838283beDouglas Gregor "InstallDir", vsExpressIDEInstallDir, sizeof(vsExpressIDEInstallDir) - 1); 376125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi // If we have both vc80 and vc90, pick version we were compiled with. 37775ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson if (hasVCDir && vsIDEInstallDir[0]) { 378620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump char *p = (char*)strstr(vsIDEInstallDir, "\\Common7\\IDE"); 379620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump if (p) 380620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump *p = '\0'; 381620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump path = vsIDEInstallDir; 382ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner return true; 38343d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump } 384ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner 385ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner if (hasVCExpressDir && vsExpressIDEInstallDir[0]) { 38680f93d9fe82ebe7e58913646248240de838283beDouglas Gregor char *p = (char*)strstr(vsExpressIDEInstallDir, "\\Common7\\IDE"); 38780f93d9fe82ebe7e58913646248240de838283beDouglas Gregor if (p) 38880f93d9fe82ebe7e58913646248240de838283beDouglas Gregor *p = '\0'; 38980f93d9fe82ebe7e58913646248240de838283beDouglas Gregor path = vsExpressIDEInstallDir; 390ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner return true; 39180f93d9fe82ebe7e58913646248240de838283beDouglas Gregor } 392ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner 393ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner // Try the environment. 394ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner const char *vs100comntools = getenv("VS100COMNTOOLS"); 395ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner const char *vs90comntools = getenv("VS90COMNTOOLS"); 396ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner const char *vs80comntools = getenv("VS80COMNTOOLS"); 397ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner const char *vscomntools = NULL; 398ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner 399ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner // Try to find the version that we were compiled with 400ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner if(false) {} 401ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner #if (_MSC_VER >= 1600) // VC100 402ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner else if(vs100comntools) { 403ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner vscomntools = vs100comntools; 404620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump } 405ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner #elif (_MSC_VER == 1500) // VC80 406ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner else if(vs90comntools) { 407ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner vscomntools = vs90comntools; 408ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner } 409ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner #elif (_MSC_VER == 1400) // VC80 410ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner else if(vs80comntools) { 411ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner vscomntools = vs80comntools; 412ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner } 413ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner #endif 414ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner // Otherwise find any version we can 415ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner else if (vs100comntools) 416ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner vscomntools = vs100comntools; 417ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner else if (vs90comntools) 418ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner vscomntools = vs90comntools; 419ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner else if (vs80comntools) 420ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner vscomntools = vs80comntools; 421ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner 422ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner if (vscomntools && *vscomntools) { 423a6c2b3a648913d47703625acb17671dd2d926bbcFrancois Pichet const char *p = strstr(vscomntools, "\\Common7\\Tools"); 424a6c2b3a648913d47703625acb17671dd2d926bbcFrancois Pichet path = p ? std::string(vscomntools, p) : vscomntools; 425ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner return true; 426ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner } 427ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner return false; 42843d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump} 4294d374d4a4832a01d5d3b75c59cb1567e60df41e7Sebastian Redl 43075ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // Get Windows SDK installation directory. 4316cd5216bb61e6165d8f6e8fb781d45c035bd4e00Benjamin Kramerstatic bool getWindowsSDKDir(std::string &path) { 43275ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson char windowsSDKInstallDir[256]; 43375ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // Try the Windows registry. 43475ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson bool hasSDKDir = getSystemRegistryString( 43575ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\$VERSION", 436ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner "InstallationFolder", 437ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner windowsSDKInstallDir, 438ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner sizeof(windowsSDKInstallDir) - 1); 439125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi // If we have both vc80 and vc90, pick version we were compiled with. 44075ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson if (hasSDKDir && windowsSDKInstallDir[0]) { 44175ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson path = windowsSDKInstallDir; 44275ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson return(true); 44375ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson } 44475ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson return(false); 44575ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson} 44675ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson 44779bc57c074cb91f574fba19215f95b63dcf6b04bmike-mvoid InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple, 44879bc57c074cb91f574fba19215f95b63dcf6b04bmike-m const HeaderSearchOptions &HSOpts) { 4498e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer llvm::Triple::OSType os = triple.getOS(); 4508e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer 4518e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer switch (os) { 452630766057eabe78f9bb2e0c0d023223fb8d0174eRoman Divacky case llvm::Triple::FreeBSD: 4538e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer case llvm::Triple::NetBSD: 4548e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer break; 4558e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer default: 4568e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer // FIXME: temporary hack: hard-coded paths. 4578e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer AddPath("/usr/local/include", System, true, false, false); 4588e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer break; 4598e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer } 46079bc57c074cb91f574fba19215f95b63dcf6b04bmike-m 46179bc57c074cb91f574fba19215f95b63dcf6b04bmike-m // Builtin includes use #include_next directives and should be positioned 46279bc57c074cb91f574fba19215f95b63dcf6b04bmike-m // just prior C include dirs. 46379bc57c074cb91f574fba19215f95b63dcf6b04bmike-m if (HSOpts.UseBuiltinIncludes) { 46479bc57c074cb91f574fba19215f95b63dcf6b04bmike-m // Ignore the sys root, we *always* look for clang headers relative to 46579bc57c074cb91f574fba19215f95b63dcf6b04bmike-m // supplied path. 46679bc57c074cb91f574fba19215f95b63dcf6b04bmike-m llvm::sys::Path P(HSOpts.ResourceDir); 46779bc57c074cb91f574fba19215f95b63dcf6b04bmike-m P.appendComponent("include"); 46879bc57c074cb91f574fba19215f95b63dcf6b04bmike-m AddPath(P.str(), System, false, false, false, /*IgnoreSysRoot=*/ true); 46979bc57c074cb91f574fba19215f95b63dcf6b04bmike-m } 47079bc57c074cb91f574fba19215f95b63dcf6b04bmike-m 47179bc57c074cb91f574fba19215f95b63dcf6b04bmike-m // Add dirs specified via 'configure --with-c-include-dirs'. 4725f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner StringRef CIncludeDirs(C_INCLUDE_DIRS); 473c706468b1e00bab49ca92eb500a39657f530f828Daniel Dunbar if (CIncludeDirs != "") { 4745f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner SmallVector<StringRef, 5> dirs; 475aadd7a48453b4f58bd8e1e9eb670918ee7d6a711Rafael Espindola CIncludeDirs.split(dirs, ":"); 4765f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner for (SmallVectorImpl<StringRef>::iterator i = dirs.begin(); 477aadd7a48453b4f58bd8e1e9eb670918ee7d6a711Rafael Espindola i != dirs.end(); 478125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi ++i) 479f0a2f51be576089e1a84cd677c09156dae067b6aRafael Espindola AddPath(*i, System, false, false, false); 480f0a2f51be576089e1a84cd677c09156dae067b6aRafael Espindola return; 481f0a2f51be576089e1a84cd677c09156dae067b6aRafael Espindola } 4828e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer 48343d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump switch (os) { 484d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar case llvm::Triple::Win32: { 485d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar std::string VSDir; 486d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar std::string WindowsSDKDir; 487d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar if (getVisualStudioDir(VSDir)) { 488d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar AddPath(VSDir + "\\VC\\include", System, false, false, false); 489d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar if (getWindowsSDKDir(WindowsSDKDir)) 490d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar AddPath(WindowsSDKDir + "\\include", System, false, false, false); 491d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar else 492d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar AddPath(VSDir + "\\VC\\PlatformSDK\\Include", 493d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar System, false, false, false); 494d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar } else { 495d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar // Default install paths. 496d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar AddPath("C:/Program Files/Microsoft Visual Studio 10.0/VC/include", 497d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar System, false, false, false); 498d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar AddPath("C:/Program Files/Microsoft Visual Studio 9.0/VC/include", 499d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar System, false, false, false); 500d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar AddPath( 5019319f02dea2449caf5c7a0d07c596ca324e43574John Thompson "C:/Program Files/Microsoft Visual Studio 9.0/VC/PlatformSDK/Include", 502d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar System, false, false, false); 503d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar AddPath("C:/Program Files/Microsoft Visual Studio 8/VC/include", 504d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar System, false, false, false); 505d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar AddPath( 5069319f02dea2449caf5c7a0d07c596ca324e43574John Thompson "C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/Include", 507d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar System, false, false, false); 50843d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump } 50943d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump break; 510d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar } 51186ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner case llvm::Triple::Haiku: 51286ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/common/include", System, true, false, false); 51386ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os", System, true, false, false); 51486ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/app", System, true, false, false); 51586ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/arch", System, true, false, false); 51686ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/device", System, true, false, false); 51786ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/drivers", System, true, false, false); 518125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi AddPath("/boot/develop/headers/os/game", System, true, false, false); 51986ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/interface", System, true, false, false); 52086ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/kernel", System, true, false, false); 52186ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/locale", System, true, false, false); 52286ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/mail", System, true, false, false); 52386ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/media", System, true, false, false); 52486ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/midi", System, true, false, false); 52586ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/midi2", System, true, false, false); 52686ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/net", System, true, false, false); 52786ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/storage", System, true, false, false); 52886ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/support", System, true, false, false); 52986ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/translation", 53086ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner System, true, false, false); 531125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi AddPath("/boot/develop/headers/os/add-ons/graphics", 53286ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner System, true, false, false); 533125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi AddPath("/boot/develop/headers/os/add-ons/input_server", 53486ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner System, true, false, false); 535125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi AddPath("/boot/develop/headers/os/add-ons/screen_saver", 53686ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner System, true, false, false); 537125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi AddPath("/boot/develop/headers/os/add-ons/tracker", 53886ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner System, true, false, false); 53986ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/be_apps/Deskbar", 54086ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner System, true, false, false); 54186ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/be_apps/NetPositive", 54286ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner System, true, false, false); 54386ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/be_apps/Tracker", 54486ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner System, true, false, false); 54586ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/cpp", System, true, false, false); 546125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi AddPath("/boot/develop/headers/cpp/i586-pc-haiku", 54786ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner System, true, false, false); 54886ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/3rdparty", System, true, false, false); 54986ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/bsd", System, true, false, false); 55086ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/glibc", System, true, false, false); 55186ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/posix", System, true, false, false); 55286ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers", System, true, false, false); 553a7e6845660f91ec611427e1db842780e1ec12bdbEli Friedman break; 554dca5226598097add5d86d57b227aa31df27f0ba4Douglas Gregor case llvm::Triple::RTEMS: 555dca5226598097add5d86d57b227aa31df27f0ba4Douglas Gregor break; 55632df002017e3e8d86bfd3f7090b341d265676fc9NAKAMURA Takumi case llvm::Triple::Cygwin: 55732df002017e3e8d86bfd3f7090b341d265676fc9NAKAMURA Takumi AddPath("/usr/include/w32api", System, true, false, false); 55832df002017e3e8d86bfd3f7090b341d265676fc9NAKAMURA Takumi break; 559d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor case llvm::Triple::MinGW32: { 560d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor // mingw-w64 crt include paths 561d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor llvm::sys::Path P(HSOpts.ResourceDir); 562d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor P.appendComponent("../../../i686-w64-mingw32/include"); // <sysroot>/i686-w64-mingw32/include 563d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddPath(P.str(), System, true, false, false); 564d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor P = llvm::sys::Path(HSOpts.ResourceDir); 565d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor P.appendComponent("../../../x86_64-w64-mingw32/include"); // <sysroot>/x86_64-w64-mingw32/include 566d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddPath(P.str(), System, true, false, false); 567d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor // mingw.org crt include paths 568d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor P = llvm::sys::Path(HSOpts.ResourceDir); 569d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor P.appendComponent("../../../include"); // <sysroot>/include 570d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddPath(P.str(), System, true, false, false); 571d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddPath("/mingw/include", System, true, false, false); 572d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddPath("c:/mingw/include", System, true, false, false); 573d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor } 57443d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump break; 575d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor 576b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher case llvm::Triple::Linux: 577b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher // Generic Debian multiarch support: 578b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher if (triple.getArch() == llvm::Triple::x86_64) { 579b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher AddPath("/usr/include/x86_64-linux-gnu", System, false, false, false); 580b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher AddPath("/usr/include/i686-linux-gnu/64", System, false, false, false); 581b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher AddPath("/usr/include/i486-linux-gnu/64", System, false, false, false); 58255ab5b0799c256a719e69ce463652839135e62f7Eric Christopher } else if (triple.getArch() == llvm::Triple::x86) { 583b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher AddPath("/usr/include/x86_64-linux-gnu/32", System, false, false, false); 584b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher AddPath("/usr/include/i686-linux-gnu", System, false, false, false); 585b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher AddPath("/usr/include/i486-linux-gnu", System, false, false, false); 58655ab5b0799c256a719e69ce463652839135e62f7Eric Christopher } else if (triple.getArch() == llvm::Triple::arm) { 58755ab5b0799c256a719e69ce463652839135e62f7Eric Christopher AddPath("/usr/include/arm-linux-gnueabi", System, false, false, false); 588b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher } 58943d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump default: 59043d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump break; 5910fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 592d3f88343af2dec3459493fafa22532317321eaf0John Thompson 593dca5226598097add5d86d57b227aa31df27f0ba4Douglas Gregor if ( os != llvm::Triple::RTEMS ) 594dca5226598097add5d86d57b227aa31df27f0ba4Douglas Gregor AddPath("/usr/include", System, false, false, false); 595e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola} 596e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola 5970e3cc05542e62fe89345ce94a73494525ee463e0Chris Lattnervoid InitHeaderSearch:: 598d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas GregorAddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple, const HeaderSearchOptions &HSOpts) { 599e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola llvm::Triple::OSType os = triple.getOS(); 6005f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner StringRef CxxIncludeRoot(CXX_INCLUDE_ROOT); 601ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola if (CxxIncludeRoot != "") { 6025f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner StringRef CxxIncludeArch(CXX_INCLUDE_ARCH); 603ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola if (CxxIncludeArch == "") 604ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola AddGnuCPlusPlusIncludePaths(CxxIncludeRoot, triple.str().c_str(), 6050e3cc05542e62fe89345ce94a73494525ee463e0Chris Lattner CXX_INCLUDE_32BIT_DIR, CXX_INCLUDE_64BIT_DIR, 6060e3cc05542e62fe89345ce94a73494525ee463e0Chris Lattner triple); 607ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola else 608ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola AddGnuCPlusPlusIncludePaths(CxxIncludeRoot, CXX_INCLUDE_ARCH, 6090e3cc05542e62fe89345ce94a73494525ee463e0Chris Lattner CXX_INCLUDE_32BIT_DIR, CXX_INCLUDE_64BIT_DIR, 6100e3cc05542e62fe89345ce94a73494525ee463e0Chris Lattner triple); 611ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola return; 612ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola } 613e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola // FIXME: temporary hack: hard-coded paths. 614db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar 615db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar if (triple.isOSDarwin()) { 616f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar switch (triple.getArch()) { 617f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar default: break; 618f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar 619125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi case llvm::Triple::ppc: 620582c30135dce1857db62e58b916ab0fa5edfb1d6Douglas Gregor case llvm::Triple::ppc64: 621616d4362f01a8f819f9351372c3c4368777d4480Douglas Gregor AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1", 622125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi "powerpc-apple-darwin10", "", "ppc64", 623616d4362f01a8f819f9351372c3c4368777d4480Douglas Gregor triple); 624582c30135dce1857db62e58b916ab0fa5edfb1d6Douglas Gregor AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.0.0", 625125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi "powerpc-apple-darwin10", "", "ppc64", 626582c30135dce1857db62e58b916ab0fa5edfb1d6Douglas Gregor triple); 627582c30135dce1857db62e58b916ab0fa5edfb1d6Douglas Gregor break; 628582c30135dce1857db62e58b916ab0fa5edfb1d6Douglas Gregor 629f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar case llvm::Triple::x86: 630f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar case llvm::Triple::x86_64: 631f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1", 632f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar "i686-apple-darwin10", "", "x86_64", triple); 633f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.0.0", 634f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar "i686-apple-darwin8", "", "", triple); 635f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar break; 636f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar 637f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar case llvm::Triple::arm: 638f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar case llvm::Triple::thumb: 639f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1", 640f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar "arm-apple-darwin10", "v7", "", triple); 641f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1", 642f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar "arm-apple-darwin10", "v6", "", triple); 643f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar break; 644f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar } 645db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar return; 646db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar } 647db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar 648db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar switch (os) { 649db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar case llvm::Triple::Cygwin: 650db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar // Cygwin-1.7 651db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "4.3.4"); 652db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar // g++-4 / Cygwin-1.5 653db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "4.3.2"); 654db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar // FIXME: Do we support g++-3.4.4? 655db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "3.4.4"); 656db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar break; 657db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar case llvm::Triple::MinGW32: 658d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor // mingw-w64 C++ include paths (i686-w64-mingw32 and x86_64-w64-mingw32) 659d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddMinGW64CXXPaths(HSOpts.ResourceDir, "4.5.0"); 660d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddMinGW64CXXPaths(HSOpts.ResourceDir, "4.5.1"); 661d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddMinGW64CXXPaths(HSOpts.ResourceDir, "4.5.2"); 662d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddMinGW64CXXPaths(HSOpts.ResourceDir, "4.5.3"); 663d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddMinGW64CXXPaths(HSOpts.ResourceDir, "4.6.0"); 664d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddMinGW64CXXPaths(HSOpts.ResourceDir, "4.6.1"); 665f732f2b11b136f34aecb95b0a2e72f5f272eb723Douglas Gregor AddMinGW64CXXPaths(HSOpts.ResourceDir, "4.6.2"); 666f732f2b11b136f34aecb95b0a2e72f5f272eb723Douglas Gregor AddMinGW64CXXPaths(HSOpts.ResourceDir, "4.7.0"); 667d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor // mingw.org C++ include paths 668d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddMinGWCPlusPlusIncludePaths("/mingw/lib/gcc", "mingw32", "4.5.2"); //MSYS 669db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", "mingw32", "4.5.0"); 670db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", "mingw32", "4.4.0"); 671db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", "mingw32", "4.3.0"); 672e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola break; 6737a7ca281bcf50b34de1ce067d3c55879b81722aeChris Lattner case llvm::Triple::DragonFly: 6742df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger AddPath("/usr/include/c++/4.1", CXXSystem, true, false, false); 6757a7ca281bcf50b34de1ce067d3c55879b81722aeChris Lattner break; 676e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola case llvm::Triple::Linux: 677ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m //===------------------------------------------------------------------===// 678ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Debian based distros. 679ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Note: these distros symlink /usr/include/c++/X.Y.Z -> X.Y 680ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m //===------------------------------------------------------------------===// 681b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher 682b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher // Ubuntu 11.11 "Oneiric Ocelot" -- gcc-4.6.0 683b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6", 684b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher "x86_64-linux-gnu", "32", "", triple); 685b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6", 686b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher "i686-linux-gnu", "", "64", triple); 687b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6", 688b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher "i486-linux-gnu", "", "64", triple); 689b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6", 690b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher "arm-linux-gnueabi", "", "", triple); 691b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher 69214a011688d52794cf58fec8197e4518a54f03d80Axel Naumann // Ubuntu 11.04 "Natty Narwhal" -- gcc-4.5.2 69314a011688d52794cf58fec8197e4518a54f03d80Axel Naumann AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5", 69414a011688d52794cf58fec8197e4518a54f03d80Axel Naumann "x86_64-linux-gnu", "32", "", triple); 69514a011688d52794cf58fec8197e4518a54f03d80Axel Naumann AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5", 69614a011688d52794cf58fec8197e4518a54f03d80Axel Naumann "i686-linux-gnu", "", "64", triple); 69714a011688d52794cf58fec8197e4518a54f03d80Axel Naumann AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5", 69814a011688d52794cf58fec8197e4518a54f03d80Axel Naumann "i486-linux-gnu", "", "64", triple); 69914a011688d52794cf58fec8197e4518a54f03d80Axel Naumann AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5", 70014a011688d52794cf58fec8197e4518a54f03d80Axel Naumann "arm-linux-gnueabi", "", "", triple); 70114a011688d52794cf58fec8197e4518a54f03d80Axel Naumann 702c12bbe5cbee8936204d286e17d8e0511dd67ddb4Rafael Espindola // Ubuntu 10.10 "Maverick Meerkat" -- gcc-4.4.5 703adafdbae908a8e798fa4940ed89f61597b3d7ca5Rafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4", 704adafdbae908a8e798fa4940ed89f61597b3d7ca5Rafael Espindola "i686-linux-gnu", "", "64", triple); 705adafdbae908a8e798fa4940ed89f61597b3d7ca5Rafael Espindola // The rest of 10.10 is the same as previous versions. 706adafdbae908a8e798fa4940ed89f61597b3d7ca5Rafael Espindola 707ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Ubuntu 10.04 LTS "Lucid Lynx" -- gcc-4.4.3 708ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Ubuntu 9.10 "Karmic Koala" -- gcc-4.4.1 709ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Debian 6.0 "squeeze" -- gcc-4.4.2 710e69f047a6c882ce36bd260a8fed0ae31114a5a7eNick Lewycky AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4", 711331e8010aed1c2175328ed470aea75e93ff70b32Torok Edwin "x86_64-linux-gnu", "32", "", triple); 712e69f047a6c882ce36bd260a8fed0ae31114a5a7eNick Lewycky AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4", 713ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i486-linux-gnu", "", "64", triple); 714db0835552ff4b640bc908a50ccd075ab63cf6fffNick Lewycky AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4", 715db0835552ff4b640bc908a50ccd075ab63cf6fffNick Lewycky "arm-linux-gnueabi", "", "", triple); 716ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Ubuntu 9.04 "Jaunty Jackalope" -- gcc-4.3.3 717ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Ubuntu 8.10 "Intrepid Ibex" -- gcc-4.3.2 718ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Debian 5.0 "lenny" -- gcc-4.3.2 719ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3", 720ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "x86_64-linux-gnu", "32", "", triple); 721ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3", 722ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i486-linux-gnu", "", "64", triple); 723e7d6c2cae6a9b9985db02cfc8bb4e7b714630ed5Rafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3", 724e7d6c2cae6a9b9985db02cfc8bb4e7b714630ed5Rafael Espindola "arm-linux-gnueabi", "", "", triple); 725ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Ubuntu 8.04.4 LTS "Hardy Heron" -- gcc-4.2.4 726ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Ubuntu 8.04.[0-3] LTS "Hardy Heron" -- gcc-4.2.3 727ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2", 728ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "x86_64-linux-gnu", "32", "", triple); 729ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2", 730ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i486-linux-gnu", "", "64", triple); 731ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Ubuntu 7.10 "Gutsy Gibbon" -- gcc-4.1.3 732ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1", 733ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "x86_64-linux-gnu", "32", "", triple); 734ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1", 735ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i486-linux-gnu", "", "64", triple); 736189a14869a36ecf8bd5edc94255a34061044efe2Nuno Lopes 737ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m //===------------------------------------------------------------------===// 738ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Redhat based distros. 739ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m //===------------------------------------------------------------------===// 7408f1cc075c36212797ef52dac0e2fe35417a6bb6bEric Christopher // Fedora 15 7418f1cc075c36212797ef52dac0e2fe35417a6bb6bEric Christopher AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.0", 7428f1cc075c36212797ef52dac0e2fe35417a6bb6bEric Christopher "x86_64-redhat-linux", "32", "", triple); 7438f1cc075c36212797ef52dac0e2fe35417a6bb6bEric Christopher AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.0", 7448f1cc075c36212797ef52dac0e2fe35417a6bb6bEric Christopher "i686-redhat-linux", "", "", triple); 7456638b3a15edea25c4b1fdf8046e71d82683d8efaRafael Espindola // Fedora 14 7466638b3a15edea25c4b1fdf8046e71d82683d8efaRafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5.1", 7476638b3a15edea25c4b1fdf8046e71d82683d8efaRafael Espindola "x86_64-redhat-linux", "32", "", triple); 7486638b3a15edea25c4b1fdf8046e71d82683d8efaRafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5.1", 7496638b3a15edea25c4b1fdf8046e71d82683d8efaRafael Espindola "i686-redhat-linux", "", "", triple); 750c37039803a18c7f0f0975a618147d336de3d3d58NAKAMURA Takumi // RHEL5(gcc44) 751c37039803a18c7f0f0975a618147d336de3d3d58NAKAMURA Takumi AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.4", 752c37039803a18c7f0f0975a618147d336de3d3d58NAKAMURA Takumi "x86_64-redhat-linux6E", "32", "", triple); 753ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Fedora 13 7544336e191cc52aa1ef72f9a542f5a6d5f9f02a825Chris Lattner AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.4", 7554336e191cc52aa1ef72f9a542f5a6d5f9f02a825Chris Lattner "x86_64-redhat-linux", "32", "", triple); 7564336e191cc52aa1ef72f9a542f5a6d5f9f02a825Chris Lattner AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.4", 7574336e191cc52aa1ef72f9a542f5a6d5f9f02a825Chris Lattner "i686-redhat-linux","", "", triple); 758ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Fedora 12 759ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.3", 7600720b5159010479c08f8264a8a209037ecf55922Chris Lattner "x86_64-redhat-linux", "32", "", triple); 761ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.3", 762ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i686-redhat-linux","", "", triple); 763ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Fedora 12 (pre-FEB-2010) 764ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.2", 765ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "x86_64-redhat-linux", "32", "", triple); 766ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.2", 767ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i686-redhat-linux","", "", triple); 768189a14869a36ecf8bd5edc94255a34061044efe2Nuno Lopes // Fedora 11 769189a14869a36ecf8bd5edc94255a34061044efe2Nuno Lopes AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.1", 770ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "x86_64-redhat-linux", "32", "", triple); 771ea00f847a0e1771b1fcfe683d3506940dc2de1ecChris Lattner AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.1", 772ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i586-redhat-linux","", "", triple); 773ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Fedora 10 774ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.2", 775ea00f847a0e1771b1fcfe683d3506940dc2de1ecChris Lattner "x86_64-redhat-linux", "32", "", triple); 776ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.2", 777ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i386-redhat-linux","", "", triple); 778ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Fedora 9 779ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.0", 780ea00f847a0e1771b1fcfe683d3506940dc2de1ecChris Lattner "x86_64-redhat-linux", "32", "", triple); 781ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.0", 782ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i386-redhat-linux", "", "", triple); 783ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Fedora 8 784ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1.2", 785ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "x86_64-redhat-linux", "", "", triple); 786ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1.2", 787ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i386-redhat-linux", "", "", triple); 788199e09a93813516a5e8f9ce2c3cd4c18d60961dbEric Christopher 789199e09a93813516a5e8f9ce2c3cd4c18d60961dbEric Christopher // RHEL 5 790199e09a93813516a5e8f9ce2c3cd4c18d60961dbEric Christopher AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1.1", 791199e09a93813516a5e8f9ce2c3cd4c18d60961dbEric Christopher "x86_64-redhat-linux", "32", "", triple); 792199e09a93813516a5e8f9ce2c3cd4c18d60961dbEric Christopher AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1.1", 793199e09a93813516a5e8f9ce2c3cd4c18d60961dbEric Christopher "i386-redhat-linux", "", "", triple); 794199e09a93813516a5e8f9ce2c3cd4c18d60961dbEric Christopher 795ea00f847a0e1771b1fcfe683d3506940dc2de1ecChris Lattner 796ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m //===------------------------------------------------------------------===// 797ea00f847a0e1771b1fcfe683d3506940dc2de1ecChris Lattner 798ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Exherbo (2010-01-25) 799ea00f847a0e1771b1fcfe683d3506940dc2de1ecChris Lattner AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.3", 800ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "x86_64-pc-linux-gnu", "32", "", triple); 801ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.3", 802ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i686-pc-linux-gnu", "", "", triple); 803ea00f847a0e1771b1fcfe683d3506940dc2de1ecChris Lattner 804e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola // openSUSE 11.1 32 bit 805e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3", 806ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "i586-suse-linux", "", "", triple); 807e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola // openSUSE 11.1 64 bit 808e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3", 809ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "x86_64-suse-linux", "32", "", triple); 810e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola // openSUSE 11.2 811e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4", 812ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "i586-suse-linux", "", "", triple); 813e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4", 814ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "x86_64-suse-linux", "", "", triple); 8159d2c06001b0c09fdb0f973cd6f8fa5555aea1b5fRafael Espindola 8169d2c06001b0c09fdb0f973cd6f8fa5555aea1b5fRafael Espindola // openSUSE 11.4 8179d2c06001b0c09fdb0f973cd6f8fa5555aea1b5fRafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5", 8189d2c06001b0c09fdb0f973cd6f8fa5555aea1b5fRafael Espindola "i586-suse-linux", "", "", triple); 8199d2c06001b0c09fdb0f973cd6f8fa5555aea1b5fRafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5", 8209d2c06001b0c09fdb0f973cd6f8fa5555aea1b5fRafael Espindola "x86_64-suse-linux", "", "", triple); 8219d2c06001b0c09fdb0f973cd6f8fa5555aea1b5fRafael Espindola 8222eb3cce91fa334be35caefedd5374c22d086ad1cDavid Chisnall // openSUSE 12.1 8232eb3cce91fa334be35caefedd5374c22d086ad1cDavid Chisnall AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6", 8242eb3cce91fa334be35caefedd5374c22d086ad1cDavid Chisnall "i586-suse-linux", "", "", triple); 8252eb3cce91fa334be35caefedd5374c22d086ad1cDavid Chisnall AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6", 8262eb3cce91fa334be35caefedd5374c22d086ad1cDavid Chisnall "x86_64-suse-linux", "", "", triple); 827e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola // Arch Linux 2008-06-24 828e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.1", 829ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "i686-pc-linux-gnu", "", "", triple); 830e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.1", 831ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "x86_64-unknown-linux-gnu", "", "", triple); 832014f9720bc53cc748aa13b0773cd67428a9e6ae4Nico Weber 833014f9720bc53cc748aa13b0773cd67428a9e6ae4Nico Weber // Arch Linux gcc 4.6 83437187cc4554d34fbbb5f168041d6acc4be028fe9Chandler Carruth AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.1", 83537187cc4554d34fbbb5f168041d6acc4be028fe9Chandler Carruth "i686-pc-linux-gnu", "", "", triple); 83637187cc4554d34fbbb5f168041d6acc4be028fe9Chandler Carruth AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.1", 83737187cc4554d34fbbb5f168041d6acc4be028fe9Chandler Carruth "x86_64-unknown-linux-gnu", "", "", triple); 838014f9720bc53cc748aa13b0773cd67428a9e6ae4Nico Weber AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.0", 839014f9720bc53cc748aa13b0773cd67428a9e6ae4Nico Weber "i686-pc-linux-gnu", "", "", triple); 840014f9720bc53cc748aa13b0773cd67428a9e6ae4Nico Weber AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.0", 841014f9720bc53cc748aa13b0773cd67428a9e6ae4Nico Weber "x86_64-unknown-linux-gnu", "", "", triple); 842014f9720bc53cc748aa13b0773cd67428a9e6ae4Nico Weber 8435370383567e32c840b728bd5d066db281710f2c1Douglas Gregor // Gentoo x86 gcc 4.5.2 8445370383567e32c840b728bd5d066db281710f2c1Douglas Gregor AddGnuCPlusPlusIncludePaths( 8455370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/g++-v4", 8465370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "i686-pc-linux-gnu", "", "", triple); 8475370383567e32c840b728bd5d066db281710f2c1Douglas Gregor // Gentoo x86 gcc 4.4.5 8485370383567e32c840b728bd5d066db281710f2c1Douglas Gregor AddGnuCPlusPlusIncludePaths( 8495370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "/usr/lib/gcc/i686-pc-linux-gnu/4.4.5/include/g++-v4", 8505370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "i686-pc-linux-gnu", "", "", triple); 8515370383567e32c840b728bd5d066db281710f2c1Douglas Gregor // Gentoo x86 gcc 4.4.4 8525370383567e32c840b728bd5d066db281710f2c1Douglas Gregor AddGnuCPlusPlusIncludePaths( 8535370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "/usr/lib/gcc/i686-pc-linux-gnu/4.4.4/include/g++-v4", 8545370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "i686-pc-linux-gnu", "", "", triple); 8555370383567e32c840b728bd5d066db281710f2c1Douglas Gregor // Gentoo x86 2010.0 stable 8560d155a5e1d6406d27df5779d0c9fb98d49a713a0Nuno Lopes AddGnuCPlusPlusIncludePaths( 8570d155a5e1d6406d27df5779d0c9fb98d49a713a0Nuno Lopes "/usr/lib/gcc/i686-pc-linux-gnu/4.4.3/include/g++-v4", 8580d155a5e1d6406d27df5779d0c9fb98d49a713a0Nuno Lopes "i686-pc-linux-gnu", "", "", triple); 859e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola // Gentoo x86 2009.1 stable 860e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths( 86140d1bb6383c14d5f8249d0640e8088a91b694c66John Thompson "/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4", 862ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "i686-pc-linux-gnu", "", "", triple); 863e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola // Gentoo x86 2009.0 stable 864e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths( 86540d1bb6383c14d5f8249d0640e8088a91b694c66John Thompson "/usr/lib/gcc/i686-pc-linux-gnu/4.3.2/include/g++-v4", 866ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "i686-pc-linux-gnu", "", "", triple); 867e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola // Gentoo x86 2008.0 stable 868e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths( 86940d1bb6383c14d5f8249d0640e8088a91b694c66John Thompson "/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4", 870ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "i686-pc-linux-gnu", "", "", triple); 8715370383567e32c840b728bd5d066db281710f2c1Douglas Gregor // Gentoo x86 llvm-gcc trunk 8725370383567e32c840b728bd5d066db281710f2c1Douglas Gregor AddGnuCPlusPlusIncludePaths( 8735370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "/usr/lib/llvm-gcc-4.2-9999/include/c++/4.2.1", 8745370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "i686-pc-linux-gnu", "", "", triple); 875fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth 8765370383567e32c840b728bd5d066db281710f2c1Douglas Gregor // Gentoo amd64 gcc 4.5.2 8775370383567e32c840b728bd5d066db281710f2c1Douglas Gregor AddGnuCPlusPlusIncludePaths( 8785370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/include/g++-v4", 8795370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "x86_64-pc-linux-gnu", "32", "", triple); 880fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth // Gentoo amd64 gcc 4.4.5 881e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths( 882fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth "/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.5/include/g++-v4", 883fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth "x86_64-pc-linux-gnu", "32", "", triple); 884fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth // Gentoo amd64 gcc 4.4.4 88570d9d4196e6531926ca18b2ca850eb218041488dEric Christopher AddGnuCPlusPlusIncludePaths( 886fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth "/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.4/include/g++-v4", 887fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth "x86_64-pc-linux-gnu", "32", "", triple); 88870d9d4196e6531926ca18b2ca850eb218041488dEric Christopher // Gentoo amd64 gcc 4.4.3 88970d9d4196e6531926ca18b2ca850eb218041488dEric Christopher AddGnuCPlusPlusIncludePaths( 89070d9d4196e6531926ca18b2ca850eb218041488dEric Christopher "/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.3/include/g++-v4", 89170d9d4196e6531926ca18b2ca850eb218041488dEric Christopher "x86_64-pc-linux-gnu", "32", "", triple); 892236a537eacbb347b5aa19a8aa2c82cdb7da8a62bNico Weber // Gentoo amd64 gcc 4.3.4 893236a537eacbb347b5aa19a8aa2c82cdb7da8a62bNico Weber AddGnuCPlusPlusIncludePaths( 894236a537eacbb347b5aa19a8aa2c82cdb7da8a62bNico Weber "/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.4/include/g++-v4", 895236a537eacbb347b5aa19a8aa2c82cdb7da8a62bNico Weber "x86_64-pc-linux-gnu", "", "", triple); 896fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth // Gentoo amd64 gcc 4.3.2 8978ad8a1cc1e39d70345d45ef1b8564ec6cbf49471Nico Weber AddGnuCPlusPlusIncludePaths( 898fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth "/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/include/g++-v4", 899fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth "x86_64-pc-linux-gnu", "", "", triple); 900fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth // Gentoo amd64 stable 901fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth AddGnuCPlusPlusIncludePaths( 902fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth "/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/include/g++-v4", 9035370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "x86_64-pc-linux-gnu", "", "", triple); 9048ad8a1cc1e39d70345d45ef1b8564ec6cbf49471Nico Weber 9056693534adb31fdd13b1ee873df3e90c99f916ad5Nick Lewycky // Gentoo amd64 llvm-gcc trunk 9066693534adb31fdd13b1ee873df3e90c99f916ad5Nick Lewycky AddGnuCPlusPlusIncludePaths( 9076693534adb31fdd13b1ee873df3e90c99f916ad5Nick Lewycky "/usr/lib/llvm-gcc-4.2-9999/include/c++/4.2.1", 9086693534adb31fdd13b1ee873df3e90c99f916ad5Nick Lewycky "x86_64-pc-linux-gnu", "", "", triple); 909fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth 910e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola break; 911e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola case llvm::Triple::FreeBSD: 912ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // FreeBSD 8.0 913ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // FreeBSD 7.3 914afe859a9a6217f177daf42ebab294a90bfe8a6abNuno Lopes AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2", "", "", "", triple); 915e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola break; 916ab079419ff2e52652be349e949202a2470f8d253Anton Korobeynikov case llvm::Triple::NetBSD: 917ab079419ff2e52652be349e949202a2470f8d253Anton Korobeynikov AddGnuCPlusPlusIncludePaths("/usr/include/g++", "", "", "", triple); 918ab079419ff2e52652be349e949202a2470f8d253Anton Korobeynikov break; 91995c0457054518102af6250e718a13a5b2ee5dbeaDaniel Dunbar case llvm::Triple::OpenBSD: { 92095c0457054518102af6250e718a13a5b2ee5dbeaDaniel Dunbar std::string t = triple.getTriple(); 92195c0457054518102af6250e718a13a5b2ee5dbeaDaniel Dunbar if (t.substr(0, 6) == "x86_64") 92295c0457054518102af6250e718a13a5b2ee5dbeaDaniel Dunbar t.replace(0, 6, "amd64"); 92395c0457054518102af6250e718a13a5b2ee5dbeaDaniel Dunbar AddGnuCPlusPlusIncludePaths("/usr/include/g++", 92495c0457054518102af6250e718a13a5b2ee5dbeaDaniel Dunbar t, "", "", triple); 92595c0457054518102af6250e718a13a5b2ee5dbeaDaniel Dunbar break; 92695c0457054518102af6250e718a13a5b2ee5dbeaDaniel Dunbar } 92738e317d6dce161b249508686cc67eb7176958762Chris Lattner case llvm::Triple::Minix: 92838e317d6dce161b249508686cc67eb7176958762Chris Lattner AddGnuCPlusPlusIncludePaths("/usr/gnu/include/c++/4.4.3", 92938e317d6dce161b249508686cc67eb7176958762Chris Lattner "", "", "", triple); 93038e317d6dce161b249508686cc67eb7176958762Chris Lattner break; 931e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola case llvm::Triple::Solaris: 932e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola // Solaris - Fall though.. 933e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola case llvm::Triple::AuroraUX: 934e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola // AuroraUX 935e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths("/opt/gcc4/include/c++/4.2.4", 936ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "i386-pc-solaris2.11", "", "", triple); 937e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola break; 938e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola default: 939e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola break; 940e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola } 941e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola} 942e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola 943e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindolavoid InitHeaderSearch::AddDefaultSystemIncludePaths(const LangOptions &Lang, 9444c2bcad7b843c10fd4a2ffd43da40bfefb4dc8baDouglas Gregor const llvm::Triple &triple, 94579bc57c074cb91f574fba19215f95b63dcf6b04bmike-m const HeaderSearchOptions &HSOpts) { 94613c4f2144b35bda21746eb60ad90e52a9bd8dcdaBob Wilson if (Lang.CPlusPlus && HSOpts.UseStandardCXXIncludes) { 947baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor if (HSOpts.UseLibcxx) { 948baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor if (triple.isOSDarwin()) { 949baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor // On Darwin, libc++ may be installed alongside the compiler in 950baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor // lib/c++/v1. 951baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor llvm::sys::Path P(HSOpts.ResourceDir); 952baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor if (!P.isEmpty()) { 953baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor P.eraseComponent(); // Remove version from foo/lib/clang/version 954baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor P.eraseComponent(); // Remove clang from foo/lib/clang 955baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor 956baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor // Get foo/lib/c++/v1 957baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor P.appendComponent("c++"); 958baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor P.appendComponent("v1"); 959baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor AddPath(P.str(), CXXSystem, true, false, false, true); 960baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor } 961baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor } 962baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor 96313c4f2144b35bda21746eb60ad90e52a9bd8dcdaBob Wilson AddPath("/usr/include/c++/v1", CXXSystem, true, false, false); 964baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor } 96513c4f2144b35bda21746eb60ad90e52a9bd8dcdaBob Wilson else 966d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddDefaultCPlusPlusIncludePaths(triple, HSOpts); 96713c4f2144b35bda21746eb60ad90e52a9bd8dcdaBob Wilson } 9686ec18a3f86c702004af66cce6ff979999a736898Rafael Espindola 96979bc57c074cb91f574fba19215f95b63dcf6b04bmike-m AddDefaultCIncludePaths(triple, HSOpts); 970e166582f8f36f4db8f4ea157538fab7fe6bf2658Daniel Dunbar 971e166582f8f36f4db8f4ea157538fab7fe6bf2658Daniel Dunbar // Add the default framework include paths on Darwin. 972db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar if (triple.isOSDarwin()) { 973e166582f8f36f4db8f4ea157538fab7fe6bf2658Daniel Dunbar AddPath("/System/Library/Frameworks", System, true, false, true); 974e166582f8f36f4db8f4ea157538fab7fe6bf2658Daniel Dunbar AddPath("/Library/Frameworks", System, true, false, true); 975e166582f8f36f4db8f4ea157538fab7fe6bf2658Daniel Dunbar } 976e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola} 977e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola 9780fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber/// RemoveDuplicates - If there are duplicate directory entries in the specified 9790fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber/// search list, remove the later (dead) ones. 9800fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weberstatic void RemoveDuplicates(std::vector<DirectoryLookup> &SearchList, 9812df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger unsigned First, bool Verbose) { 9820fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber llvm::SmallPtrSet<const DirectoryEntry *, 8> SeenDirs; 9830fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber llvm::SmallPtrSet<const DirectoryEntry *, 8> SeenFrameworkDirs; 9840fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber llvm::SmallPtrSet<const HeaderMap *, 8> SeenHeaderMaps; 9852df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger for (unsigned i = First; i != SearchList.size(); ++i) { 9867a739401983eb9bc25c9b4b25177e116f5e5ba92Chris Lattner unsigned DirToRemove = i; 9871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 98843eee07270bf1966ea7289310066aa670c4b647fChris Lattner const DirectoryLookup &CurEntry = SearchList[i]; 9891eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 99043eee07270bf1966ea7289310066aa670c4b647fChris Lattner if (CurEntry.isNormalDir()) { 9910fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // If this isn't the first time we've seen this dir, remove it. 99243eee07270bf1966ea7289310066aa670c4b647fChris Lattner if (SeenDirs.insert(CurEntry.getDir())) 9930fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber continue; 99443eee07270bf1966ea7289310066aa670c4b647fChris Lattner } else if (CurEntry.isFramework()) { 9950fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // If this isn't the first time we've seen this framework dir, remove it. 99643eee07270bf1966ea7289310066aa670c4b647fChris Lattner if (SeenFrameworkDirs.insert(CurEntry.getFrameworkDir())) 9970fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber continue; 9980fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } else { 99943eee07270bf1966ea7289310066aa670c4b647fChris Lattner assert(CurEntry.isHeaderMap() && "Not a headermap or normal dir?"); 10000fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // If this isn't the first time we've seen this headermap, remove it. 100143eee07270bf1966ea7289310066aa670c4b647fChris Lattner if (SeenHeaderMaps.insert(CurEntry.getHeaderMap())) 10020fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber continue; 100330f05b553db067c994966daca37e75324ee7b424Chris Lattner } 10041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 100530f05b553db067c994966daca37e75324ee7b424Chris Lattner // If we have a normal #include dir/framework/headermap that is shadowed 100630f05b553db067c994966daca37e75324ee7b424Chris Lattner // later in the chain by a system include location, we actually want to 100730f05b553db067c994966daca37e75324ee7b424Chris Lattner // ignore the user's request and drop the user dir... keeping the system 100830f05b553db067c994966daca37e75324ee7b424Chris Lattner // dir. This is weird, but required to emulate GCC's search path correctly. 100930f05b553db067c994966daca37e75324ee7b424Chris Lattner // 101030f05b553db067c994966daca37e75324ee7b424Chris Lattner // Since dupes of system dirs are rare, just rescan to find the original 101130f05b553db067c994966daca37e75324ee7b424Chris Lattner // that we're nuking instead of using a DenseMap. 101243eee07270bf1966ea7289310066aa670c4b647fChris Lattner if (CurEntry.getDirCharacteristic() != SrcMgr::C_User) { 101330f05b553db067c994966daca37e75324ee7b424Chris Lattner // Find the dir that this is the same of. 101430f05b553db067c994966daca37e75324ee7b424Chris Lattner unsigned FirstDir; 101530f05b553db067c994966daca37e75324ee7b424Chris Lattner for (FirstDir = 0; ; ++FirstDir) { 101630f05b553db067c994966daca37e75324ee7b424Chris Lattner assert(FirstDir != i && "Didn't find dupe?"); 10171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 101843eee07270bf1966ea7289310066aa670c4b647fChris Lattner const DirectoryLookup &SearchEntry = SearchList[FirstDir]; 101943eee07270bf1966ea7289310066aa670c4b647fChris Lattner 102030f05b553db067c994966daca37e75324ee7b424Chris Lattner // If these are different lookup types, then they can't be the dupe. 102143eee07270bf1966ea7289310066aa670c4b647fChris Lattner if (SearchEntry.getLookupType() != CurEntry.getLookupType()) 102230f05b553db067c994966daca37e75324ee7b424Chris Lattner continue; 10231eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 102430f05b553db067c994966daca37e75324ee7b424Chris Lattner bool isSame; 102543eee07270bf1966ea7289310066aa670c4b647fChris Lattner if (CurEntry.isNormalDir()) 102643eee07270bf1966ea7289310066aa670c4b647fChris Lattner isSame = SearchEntry.getDir() == CurEntry.getDir(); 102743eee07270bf1966ea7289310066aa670c4b647fChris Lattner else if (CurEntry.isFramework()) 102843eee07270bf1966ea7289310066aa670c4b647fChris Lattner isSame = SearchEntry.getFrameworkDir() == CurEntry.getFrameworkDir(); 102930f05b553db067c994966daca37e75324ee7b424Chris Lattner else { 103043eee07270bf1966ea7289310066aa670c4b647fChris Lattner assert(CurEntry.isHeaderMap() && "Not a headermap or normal dir?"); 103143eee07270bf1966ea7289310066aa670c4b647fChris Lattner isSame = SearchEntry.getHeaderMap() == CurEntry.getHeaderMap(); 103230f05b553db067c994966daca37e75324ee7b424Chris Lattner } 10331eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 103430f05b553db067c994966daca37e75324ee7b424Chris Lattner if (isSame) 103530f05b553db067c994966daca37e75324ee7b424Chris Lattner break; 103630f05b553db067c994966daca37e75324ee7b424Chris Lattner } 10371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 103830f05b553db067c994966daca37e75324ee7b424Chris Lattner // If the first dir in the search path is a non-system dir, zap it 103930f05b553db067c994966daca37e75324ee7b424Chris Lattner // instead of the system one. 104030f05b553db067c994966daca37e75324ee7b424Chris Lattner if (SearchList[FirstDir].getDirCharacteristic() == SrcMgr::C_User) 104130f05b553db067c994966daca37e75324ee7b424Chris Lattner DirToRemove = FirstDir; 104230f05b553db067c994966daca37e75324ee7b424Chris Lattner } 104330f05b553db067c994966daca37e75324ee7b424Chris Lattner 104430f05b553db067c994966daca37e75324ee7b424Chris Lattner if (Verbose) { 1045e7cb7e4570842297f698bd7fd8d85520fc008acdDaniel Dunbar llvm::errs() << "ignoring duplicate directory \"" 1046e7cb7e4570842297f698bd7fd8d85520fc008acdDaniel Dunbar << CurEntry.getName() << "\"\n"; 104730f05b553db067c994966daca37e75324ee7b424Chris Lattner if (DirToRemove != i) 1048e7cb7e4570842297f698bd7fd8d85520fc008acdDaniel Dunbar llvm::errs() << " as it is a non-system directory that duplicates " 1049e7cb7e4570842297f698bd7fd8d85520fc008acdDaniel Dunbar << "a system directory\n"; 10500fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 10511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 10527a739401983eb9bc25c9b4b25177e116f5e5ba92Chris Lattner // This is reached if the current entry is a duplicate. Remove the 10537a739401983eb9bc25c9b4b25177e116f5e5ba92Chris Lattner // DirToRemove (usually the current dir). 10547a739401983eb9bc25c9b4b25177e116f5e5ba92Chris Lattner SearchList.erase(SearchList.begin()+DirToRemove); 10550fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber --i; 10560fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 10570fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber} 10580fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber 10590fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber 10602df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenbergervoid InitHeaderSearch::Realize(const LangOptions &Lang) { 10610fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // Concatenate ANGLE+SYSTEM+AFTER chains together into SearchList. 10620fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber std::vector<DirectoryLookup> SearchList; 10632df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger SearchList.reserve(IncludePath.size()); 10641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1065ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner // Quoted arguments go first. 10662df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger for (path_iterator it = IncludePath.begin(), ie = IncludePath.end(); 10672df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger it != ie; ++it) { 10682df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger if (it->first == Quoted) 10692df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger SearchList.push_back(it->second); 10702df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger } 1071ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner // Deduplicate and remember index. 10722df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger RemoveDuplicates(SearchList, 0, Verbose); 1073ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner unsigned NumQuoted = SearchList.size(); 10742df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger 10752df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger for (path_iterator it = IncludePath.begin(), ie = IncludePath.end(); 10762df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger it != ie; ++it) { 107765e02fa80e1c185f18e5f81cefc30d75383a7301Douglas Gregor if (it->first == Angled || it->first == IndexHeaderMap) 10782df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger SearchList.push_back(it->second); 10792df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger } 1080ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner 1081ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner RemoveDuplicates(SearchList, NumQuoted, Verbose); 1082ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner unsigned NumAngled = SearchList.size(); 10832df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger 10842df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger for (path_iterator it = IncludePath.begin(), ie = IncludePath.end(); 10852df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger it != ie; ++it) { 10862df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger if (it->first == System || (Lang.CPlusPlus && it->first == CXXSystem)) 10872df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger SearchList.push_back(it->second); 10882df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger } 10892df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger 10902df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger for (path_iterator it = IncludePath.begin(), ie = IncludePath.end(); 10912df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger it != ie; ++it) { 10922df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger if (it->first == After) 10932df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger SearchList.push_back(it->second); 10942df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger } 10951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 10961d7f12b83340610f76a73d21cac391e6feced7aaChris Lattner // Remove duplicates across both the Angled and System directories. GCC does 10971d7f12b83340610f76a73d21cac391e6feced7aaChris Lattner // this and failing to remove duplicates across these two groups breaks 10981d7f12b83340610f76a73d21cac391e6feced7aaChris Lattner // #include_next. 10991d7f12b83340610f76a73d21cac391e6feced7aaChris Lattner RemoveDuplicates(SearchList, NumQuoted, Verbose); 11000fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber 11010fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber bool DontSearchCurDir = false; // TODO: set to true if -I- is set? 1102ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner Headers.SetSearchPaths(SearchList, NumQuoted, NumAngled, DontSearchCurDir); 11030fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber 11040fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // If verbose, print the list of directories that will be searched. 11050fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber if (Verbose) { 1106e7cb7e4570842297f698bd7fd8d85520fc008acdDaniel Dunbar llvm::errs() << "#include \"...\" search starts here:\n"; 11070fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber for (unsigned i = 0, e = SearchList.size(); i != e; ++i) { 1108ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner if (i == NumQuoted) 1109e7cb7e4570842297f698bd7fd8d85520fc008acdDaniel Dunbar llvm::errs() << "#include <...> search starts here:\n"; 11100fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber const char *Name = SearchList[i].getName(); 11110fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber const char *Suffix; 11120fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber if (SearchList[i].isNormalDir()) 11130fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber Suffix = ""; 11140fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber else if (SearchList[i].isFramework()) 11150fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber Suffix = " (framework directory)"; 11160fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber else { 11170fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber assert(SearchList[i].isHeaderMap() && "Unknown DirectoryLookup"); 11180fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber Suffix = " (headermap)"; 11190fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 1120e7cb7e4570842297f698bd7fd8d85520fc008acdDaniel Dunbar llvm::errs() << " " << Name << Suffix << "\n"; 11210fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 1122e7cb7e4570842297f698bd7fd8d85520fc008acdDaniel Dunbar llvm::errs() << "End of search list.\n"; 11230fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 11240fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber} 112563c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar 11265814e657c9ad9ef6049a2a4af0d2aad248a8a15cDaniel Dunbarvoid clang::ApplyHeaderSearchOptions(HeaderSearch &HS, 11275814e657c9ad9ef6049a2a4af0d2aad248a8a15cDaniel Dunbar const HeaderSearchOptions &HSOpts, 11285814e657c9ad9ef6049a2a4af0d2aad248a8a15cDaniel Dunbar const LangOptions &Lang, 112963c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar const llvm::Triple &Triple) { 113063c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar InitHeaderSearch Init(HS, HSOpts.Verbose, HSOpts.Sysroot); 113163c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar 113263c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar // Add the user defined entries. 113363c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar for (unsigned i = 0, e = HSOpts.UserEntries.size(); i != e; ++i) { 113463c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar const HeaderSearchOptions::Entry &E = HSOpts.UserEntries[i]; 11351b483e70ad3f670f6dd0bc62dbe0921a28195f24Daniel Dunbar Init.AddPath(E.Path, E.Group, false, E.IsUserSupplied, E.IsFramework, 11365dd45f13dc4463f0c18b923fe6795ce55103301dBob Wilson E.IgnoreSysRoot); 113763c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar } 113863c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar 113963c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar // Add entries from CPATH and friends. 11409e9ddf6100fd50ca2f9f9d0106b856e20b43300fBenjamin Kramer Init.AddDelimitedPaths(HSOpts.EnvIncPath); 1141c363cb1929c7908c8c8c4b77d025c2ccb09284aeDaniel Dunbar if (Lang.CPlusPlus && Lang.ObjC1) 11429e9ddf6100fd50ca2f9f9d0106b856e20b43300fBenjamin Kramer Init.AddDelimitedPaths(HSOpts.ObjCXXEnvIncPath); 1143c363cb1929c7908c8c8c4b77d025c2ccb09284aeDaniel Dunbar else if (Lang.CPlusPlus) 11449e9ddf6100fd50ca2f9f9d0106b856e20b43300fBenjamin Kramer Init.AddDelimitedPaths(HSOpts.CXXEnvIncPath); 1145c363cb1929c7908c8c8c4b77d025c2ccb09284aeDaniel Dunbar else if (Lang.ObjC1) 11469e9ddf6100fd50ca2f9f9d0106b856e20b43300fBenjamin Kramer Init.AddDelimitedPaths(HSOpts.ObjCEnvIncPath); 1147c363cb1929c7908c8c8c4b77d025c2ccb09284aeDaniel Dunbar else 11489e9ddf6100fd50ca2f9f9d0106b856e20b43300fBenjamin Kramer Init.AddDelimitedPaths(HSOpts.CEnvIncPath); 114963c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar 1150dd35ce9a783dea7e6660f9cb1d973742f3b3c73fDaniel Dunbar if (HSOpts.UseStandardIncludes) 115179bc57c074cb91f574fba19215f95b63dcf6b04bmike-m Init.AddDefaultSystemIncludePaths(Lang, Triple, HSOpts); 115263c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar 11532df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger Init.Realize(Lang); 115463c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar} 1155