InitHeaderSearch.cpp revision e305e81f65d13e6953f623a6b31176ad7041ba20
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 // AddDefaultCIncludePaths - Add paths that should always be searched. 8579bc57c074cb91f574fba19215f95b63dcf6b04bmike-m void AddDefaultCIncludePaths(const llvm::Triple &triple, 8679bc57c074cb91f574fba19215f95b63dcf6b04bmike-m const HeaderSearchOptions &HSOpts); 872cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar 882cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar // AddDefaultCPlusPlusIncludePaths - Add paths that should be searched when 892cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar // compiling c++. 90d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor void AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple, 91d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor const HeaderSearchOptions &HSOpts); 922cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar 932cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar /// AddDefaultSystemIncludePaths - Adds the default system include paths so 942cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar /// that e.g. stdio.h is found. 952cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar void AddDefaultSystemIncludePaths(const LangOptions &Lang, 964c2bcad7b843c10fd4a2ffd43da40bfefb4dc8baDouglas Gregor const llvm::Triple &triple, 9779bc57c074cb91f574fba19215f95b63dcf6b04bmike-m const HeaderSearchOptions &HSOpts); 982cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar 992cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar /// Realize - Merges all search path lists into one list and send it to 1002cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar /// HeaderSearch. 1012df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger void Realize(const LangOptions &Lang); 1022cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar}; 1032cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar 104ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner} // end anonymous namespace. 1050fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber 1065f9e272e632e951b1efe824cd16acb4d96077930Chris Lattnervoid InitHeaderSearch::AddPath(const Twine &Path, 107458fb10ef5ba2d7b375c6c64095c1458af0a5be3Benjamin Kramer IncludeDirGroup Group, bool isCXXAware, 108458fb10ef5ba2d7b375c6c64095c1458af0a5be3Benjamin Kramer bool isUserSupplied, bool isFramework, 109458fb10ef5ba2d7b375c6c64095c1458af0a5be3Benjamin Kramer bool IgnoreSysRoot) { 110e89ba59005479529f5567f12b436617a2ca73ec2Benjamin Kramer assert(!Path.isTriviallyEmpty() && "can't handle empty path here"); 1110fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber FileManager &FM = Headers.getFileMgr(); 1121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1130fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // Compute the actual path, taking into consideration -isysroot. 1145853b0f117ee811388219bce738b24835b8d7fb2Chandler Carruth llvm::SmallString<256> MappedPathStorage; 1155f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner StringRef MappedPathStr = Path.toStringRef(MappedPathStorage); 1161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1170fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // Handle isysroot. 1189a7e09d82f739c8fd1b6c28787397d698515a871Rafael Espindola if ((Group == System || Group == CXXSystem) && !IgnoreSysRoot && 1190f0cdab31a4f71914b7f654501d69d96e9f378daNAKAMURA Takumi#if defined(_WIN32) 1200f0cdab31a4f71914b7f654501d69d96e9f378daNAKAMURA Takumi !MappedPathStr.empty() && 1210f0cdab31a4f71914b7f654501d69d96e9f378daNAKAMURA Takumi llvm::sys::path::is_separator(MappedPathStr[0]) && 1220f0cdab31a4f71914b7f654501d69d96e9f378daNAKAMURA Takumi#else 123256053b31e697fdf0cc48f17d621c82fc3b8dff0Michael J. Spencer llvm::sys::path::is_absolute(MappedPathStr) && 1240f0cdab31a4f71914b7f654501d69d96e9f378daNAKAMURA Takumi#endif 125af6530c938bfc60902f0dfec1c0808aedbee1663Michael J. Spencer IsNotEmptyOrRoot) { 1265619ae5d25dc77410a444c86606d4ec9bae8b921Chandler Carruth MappedPathStorage.clear(); 127c09265a5fd94af5dcfd7325d0cb4f04197d65afcChandler Carruth MappedPathStr = 128af6530c938bfc60902f0dfec1c0808aedbee1663Michael J. Spencer (IncludeSysroot + Path).toStringRef(MappedPathStorage); 1290fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 1301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1310fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // Compute the DirectoryLookup type. 1329d72851fec9e9c62570a027d42701562bbf29751Chris Lattner SrcMgr::CharacteristicKind Type; 13365e02fa80e1c185f18e5f81cefc30d75383a7301Douglas Gregor if (Group == Quoted || Group == Angled || Group == IndexHeaderMap) 1340b9e736308af5397f558ffc8e780c438c2fdb563Chris Lattner Type = SrcMgr::C_User; 1350fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber else if (isCXXAware) 1360b9e736308af5397f558ffc8e780c438c2fdb563Chris Lattner Type = SrcMgr::C_System; 1370fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber else 1380b9e736308af5397f558ffc8e780c438c2fdb563Chris Lattner Type = SrcMgr::C_ExternCSystem; 1391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1401eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1410fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // If the directory exists, add it. 14239b49bcaaddb1049234fca9500c0ac02c088e23dChris Lattner if (const DirectoryEntry *DE = FM.getDirectory(MappedPathStr)) { 1432df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger IncludePath.push_back(std::make_pair(Group, DirectoryLookup(DE, Type, 1442df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger isUserSupplied, isFramework))); 1450fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber return; 1460fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 1471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1480fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // Check to see if this is an apple-style headermap (which are not allowed to 1490fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // be frameworks). 1500fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber if (!isFramework) { 15139b49bcaaddb1049234fca9500c0ac02c088e23dChris Lattner if (const FileEntry *FE = FM.getFile(MappedPathStr)) { 1520fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber if (const HeaderMap *HM = Headers.CreateHeaderMap(FE)) { 1530fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // It is a headermap, add it to the search path. 1542df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger IncludePath.push_back(std::make_pair(Group, DirectoryLookup(HM, Type, 15565e02fa80e1c185f18e5f81cefc30d75383a7301Douglas Gregor isUserSupplied, Group == IndexHeaderMap))); 1560fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber return; 1570fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 1580fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 1590fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 1601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1610fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber if (Verbose) 162f3721457cd9f364f262e7a2d61edcdad05996e61Chandler Carruth llvm::errs() << "ignoring nonexistent directory \"" 163f3721457cd9f364f262e7a2d61edcdad05996e61Chandler Carruth << MappedPathStr << "\"\n"; 1640fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber} 1650fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber 1665f9e272e632e951b1efe824cd16acb4d96077930Chris Lattnervoid InitHeaderSearch::AddGnuCPlusPlusIncludePaths(StringRef Base, 1675f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner StringRef ArchDir, 1685f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner StringRef Dir32, 1695f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner StringRef Dir64, 17031b63beefa058aa42a12a1c2b72b43a4ba21f7f1Rafael Espindola const llvm::Triple &triple) { 1716ec18a3f86c702004af66cce6ff979999a736898Rafael Espindola // Add the base dir 1722df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger AddPath(Base, CXXSystem, true, false, false); 173ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola 174ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola // Add the multilib dirs 17531b63beefa058aa42a12a1c2b72b43a4ba21f7f1Rafael Espindola llvm::Triple::ArchType arch = triple.getArch(); 17631b63beefa058aa42a12a1c2b72b43a4ba21f7f1Rafael Espindola bool is64bit = arch == llvm::Triple::ppc64 || arch == llvm::Triple::x86_64; 17731b63beefa058aa42a12a1c2b72b43a4ba21f7f1Rafael Espindola if (is64bit) 1782df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger AddPath(Base + "/" + ArchDir + "/" + Dir64, CXXSystem, true, false, false); 17931b63beefa058aa42a12a1c2b72b43a4ba21f7f1Rafael Espindola else 1802df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger AddPath(Base + "/" + ArchDir + "/" + Dir32, CXXSystem, true, false, false); 1816ec18a3f86c702004af66cce6ff979999a736898Rafael Espindola 1826ec18a3f86c702004af66cce6ff979999a736898Rafael Espindola // Add the backward dir 1832df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger AddPath(Base + "/backward", CXXSystem, true, false, false); 1842e9f652d53346bf7e64c8a12a9ff06b004a3e489Rafael Espindola} 1850fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber 1865f9e272e632e951b1efe824cd16acb4d96077930Chris Lattnervoid InitHeaderSearch::AddMinGWCPlusPlusIncludePaths(StringRef Base, 1875f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner StringRef Arch, 1885f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner StringRef Version) { 189ab8ae19ea4285a15ca43123e8e218e401dc5cb5aBenjamin Kramer AddPath(Base + "/" + Arch + "/" + Version + "/include/c++", 1902df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger CXXSystem, true, false, false); 1918e9006bb31184a38b7c4c9d3d3040394652cbd9bChris Lattner AddPath(Base + "/" + Arch + "/" + Version + "/include/c++/" + Arch, 1922df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger CXXSystem, true, false, false); 193ab8ae19ea4285a15ca43123e8e218e401dc5cb5aBenjamin Kramer AddPath(Base + "/" + Arch + "/" + Version + "/include/c++/backward", 1942df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger CXXSystem, true, false, false); 195620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump} 19643d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump 1975f9e272e632e951b1efe824cd16acb4d96077930Chris Lattnervoid InitHeaderSearch::AddMinGW64CXXPaths(StringRef Base, 1985f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner StringRef Version) { 199d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor // Assumes Base is HeaderSearchOpts' ResourceDir 200d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddPath(Base + "/../../../include/c++/" + Version, 2019db48467f19d4f0929a5ba40c5e2bd7255dc95f0NAKAMURA Takumi CXXSystem, true, false, false); 202d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddPath(Base + "/../../../include/c++/" + Version + "/x86_64-w64-mingw32", 2039db48467f19d4f0929a5ba40c5e2bd7255dc95f0NAKAMURA Takumi CXXSystem, true, false, false); 204d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddPath(Base + "/../../../include/c++/" + Version + "/i686-w64-mingw32", 205d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor CXXSystem, true, false, false); 206d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddPath(Base + "/../../../include/c++/" + Version + "/backward", 2079db48467f19d4f0929a5ba40c5e2bd7255dc95f0NAKAMURA Takumi CXXSystem, true, false, false); 2089db48467f19d4f0929a5ba40c5e2bd7255dc95f0NAKAMURA Takumi} 2099db48467f19d4f0929a5ba40c5e2bd7255dc95f0NAKAMURA Takumi 210620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump // FIXME: This probably should goto to some platform utils place. 211620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump#ifdef _MSC_VER 21275ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson 213620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump // Read registry string. 21475ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // This also supports a means to look for high-versioned keys by use 21575ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // of a $VERSION placeholder in the key path. 21675ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // $VERSION in the key path is a placeholder for the version number, 21775ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // causing the highest value path to be searched for and used. 21875ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // I.e. "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\$VERSION". 21975ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // There can be additional characters in the component. Only the numberic 22075ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // characters are compared. 2216cd5216bb61e6165d8f6e8fb781d45c035bd4e00Benjamin Kramerstatic bool getSystemRegistryString(const char *keyPath, const char *valueName, 2226cd5216bb61e6165d8f6e8fb781d45c035bd4e00Benjamin Kramer char *value, size_t maxLength) { 22343d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump HKEY hRootKey = NULL; 22443d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump HKEY hKey = NULL; 22543d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump const char* subKey = NULL; 22643d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump DWORD valueType; 22743d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump DWORD valueSize = maxLength - 1; 22875ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson long lResult; 22943d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump bool returnValue = false; 230ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner 23143d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump if (strncmp(keyPath, "HKEY_CLASSES_ROOT\\", 18) == 0) { 23243d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump hRootKey = HKEY_CLASSES_ROOT; 23343d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump subKey = keyPath + 18; 234ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner } else if (strncmp(keyPath, "HKEY_USERS\\", 11) == 0) { 23543d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump hRootKey = HKEY_USERS; 23643d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump subKey = keyPath + 11; 237ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner } else if (strncmp(keyPath, "HKEY_LOCAL_MACHINE\\", 19) == 0) { 23843d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump hRootKey = HKEY_LOCAL_MACHINE; 23943d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump subKey = keyPath + 19; 240ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner } else if (strncmp(keyPath, "HKEY_CURRENT_USER\\", 18) == 0) { 24143d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump hRootKey = HKEY_CURRENT_USER; 24243d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump subKey = keyPath + 18; 24343d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump } 24443d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump else 245ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner return false; 246ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner 24775ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson const char *placeHolder = strstr(subKey, "$VERSION"); 24875ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson char bestName[256]; 24975ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson bestName[0] = '\0'; 25075ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // If we have a $VERSION placeholder, do the highest-version search. 25175ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson if (placeHolder) { 25275ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson const char *keyEnd = placeHolder - 1; 25375ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson const char *nextKey = placeHolder; 25475ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // Find end of previous key. 25575ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson while ((keyEnd > subKey) && (*keyEnd != '\\')) 25675ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson keyEnd--; 25775ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // Find end of key containing $VERSION. 25875ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson while (*nextKey && (*nextKey != '\\')) 25975ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson nextKey++; 26075ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson size_t partialKeyLength = keyEnd - subKey; 26175ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson char partialKey[256]; 26275ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson if (partialKeyLength > sizeof(partialKey)) 26375ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson partialKeyLength = sizeof(partialKey); 26475ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson strncpy(partialKey, subKey, partialKeyLength); 26575ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson partialKey[partialKeyLength] = '\0'; 26675ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson HKEY hTopKey = NULL; 26775ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson lResult = RegOpenKeyEx(hRootKey, partialKey, 0, KEY_READ, &hTopKey); 26875ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson if (lResult == ERROR_SUCCESS) { 26975ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson char keyName[256]; 27075ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson int bestIndex = -1; 27175ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson double bestValue = 0.0; 27275ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson DWORD index, size = sizeof(keyName) - 1; 27333cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes for (index = 0; RegEnumKeyEx(hTopKey, index, keyName, &size, NULL, 27433cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes NULL, NULL, NULL) == ERROR_SUCCESS; index++) { 27533cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes const char *sp = keyName; 27633cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes while (*sp && !isdigit(*sp)) 27733cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes sp++; 27833cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes if (!*sp) 27933cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes continue; 28033cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes const char *ep = sp + 1; 28133cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes while (*ep && (isdigit(*ep) || (*ep == '.'))) 28233cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes ep++; 28333cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes char numBuf[32]; 28433cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes strncpy(numBuf, sp, sizeof(numBuf) - 1); 28533cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes numBuf[sizeof(numBuf) - 1] = '\0'; 28633cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes double value = strtod(numBuf, NULL); 28733cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes if (value > bestValue) { 28833cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes bestIndex = (int)index; 28933cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes bestValue = value; 29033cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes strcpy(bestName, keyName); 29133cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes } 29275ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson size = sizeof(keyName) - 1; 29375ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson } 29475ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // If we found the highest versioned key, open the key and get the value. 29575ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson if (bestIndex != -1) { 29675ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // Append rest of key. 29775ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson strncat(bestName, nextKey, sizeof(bestName) - 1); 29875ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson bestName[sizeof(bestName) - 1] = '\0'; 29975ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // Open the chosen key path remainder. 30075ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson lResult = RegOpenKeyEx(hTopKey, bestName, 0, KEY_READ, &hKey); 30175ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson if (lResult == ERROR_SUCCESS) { 30275ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson lResult = RegQueryValueEx(hKey, valueName, NULL, &valueType, 30375ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson (LPBYTE)value, &valueSize); 30475ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson if (lResult == ERROR_SUCCESS) 30575ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson returnValue = true; 30675ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson RegCloseKey(hKey); 30775ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson } 30875ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson } 30975ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson RegCloseKey(hTopKey); 31075ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson } 31175ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson } 31275ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson else { 31375ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson lResult = RegOpenKeyEx(hRootKey, subKey, 0, KEY_READ, &hKey); 31475ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson if (lResult == ERROR_SUCCESS) { 31575ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson lResult = RegQueryValueEx(hKey, valueName, NULL, &valueType, 31675ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson (LPBYTE)value, &valueSize); 31775ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson if (lResult == ERROR_SUCCESS) 31875ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson returnValue = true; 31975ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson RegCloseKey(hKey); 32075ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson } 32143d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump } 322ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner return returnValue; 32343d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump} 324620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump#else // _MSC_VER 325620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump // Read registry string. 3266cd5216bb61e6165d8f6e8fb781d45c035bd4e00Benjamin Kramerstatic bool getSystemRegistryString(const char*, const char*, char*, size_t) { 327620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump return(false); 328620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump} 329620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump#endif // _MSC_VER 330121e3c207415fb4c105d690de384d8f3d49b0f2dArgyrios Kyrtzidis 33143d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump // Get Visual Studio installation directory. 3326cd5216bb61e6165d8f6e8fb781d45c035bd4e00Benjamin Kramerstatic bool getVisualStudioDir(std::string &path) { 333ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer // First check the environment variables that vsvars32.bat sets. 334ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer const char* vcinstalldir = getenv("VCINSTALLDIR"); 335ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner if (vcinstalldir) { 336ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer char *p = const_cast<char *>(strstr(vcinstalldir, "\\VC")); 337ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer if (p) 338ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer *p = '\0'; 339ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer path = vcinstalldir; 340ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner return true; 341ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer } 342ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer 34375ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson char vsIDEInstallDir[256]; 34480f93d9fe82ebe7e58913646248240de838283beDouglas Gregor char vsExpressIDEInstallDir[256]; 345ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer // Then try the windows registry. 34675ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson bool hasVCDir = getSystemRegistryString( 34775ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\$VERSION", 34875ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson "InstallDir", vsIDEInstallDir, sizeof(vsIDEInstallDir) - 1); 34980f93d9fe82ebe7e58913646248240de838283beDouglas Gregor bool hasVCExpressDir = getSystemRegistryString( 35080f93d9fe82ebe7e58913646248240de838283beDouglas Gregor "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\$VERSION", 35180f93d9fe82ebe7e58913646248240de838283beDouglas Gregor "InstallDir", vsExpressIDEInstallDir, sizeof(vsExpressIDEInstallDir) - 1); 352125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi // If we have both vc80 and vc90, pick version we were compiled with. 35375ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson if (hasVCDir && vsIDEInstallDir[0]) { 354620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump char *p = (char*)strstr(vsIDEInstallDir, "\\Common7\\IDE"); 355620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump if (p) 356620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump *p = '\0'; 357620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump path = vsIDEInstallDir; 358ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner return true; 35943d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump } 360ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner 361ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner if (hasVCExpressDir && vsExpressIDEInstallDir[0]) { 36280f93d9fe82ebe7e58913646248240de838283beDouglas Gregor char *p = (char*)strstr(vsExpressIDEInstallDir, "\\Common7\\IDE"); 36380f93d9fe82ebe7e58913646248240de838283beDouglas Gregor if (p) 36480f93d9fe82ebe7e58913646248240de838283beDouglas Gregor *p = '\0'; 36580f93d9fe82ebe7e58913646248240de838283beDouglas Gregor path = vsExpressIDEInstallDir; 366ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner return true; 36780f93d9fe82ebe7e58913646248240de838283beDouglas Gregor } 368ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner 369ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner // Try the environment. 370ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner const char *vs100comntools = getenv("VS100COMNTOOLS"); 371ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner const char *vs90comntools = getenv("VS90COMNTOOLS"); 372ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner const char *vs80comntools = getenv("VS80COMNTOOLS"); 373ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner const char *vscomntools = NULL; 374ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner 375ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner // Try to find the version that we were compiled with 376ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner if(false) {} 377ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner #if (_MSC_VER >= 1600) // VC100 378ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner else if(vs100comntools) { 379ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner vscomntools = vs100comntools; 380620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump } 381ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner #elif (_MSC_VER == 1500) // VC80 382ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner else if(vs90comntools) { 383ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner vscomntools = vs90comntools; 384ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner } 385ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner #elif (_MSC_VER == 1400) // VC80 386ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner else if(vs80comntools) { 387ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner vscomntools = vs80comntools; 388ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner } 389ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner #endif 390ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner // Otherwise find any version we can 391ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner else if (vs100comntools) 392ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner vscomntools = vs100comntools; 393ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner else if (vs90comntools) 394ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner vscomntools = vs90comntools; 395ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner else if (vs80comntools) 396ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner vscomntools = vs80comntools; 397ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner 398ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner if (vscomntools && *vscomntools) { 399a6c2b3a648913d47703625acb17671dd2d926bbcFrancois Pichet const char *p = strstr(vscomntools, "\\Common7\\Tools"); 400a6c2b3a648913d47703625acb17671dd2d926bbcFrancois Pichet path = p ? std::string(vscomntools, p) : vscomntools; 401ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner return true; 402ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner } 403ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner return false; 40443d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump} 4054d374d4a4832a01d5d3b75c59cb1567e60df41e7Sebastian Redl 40675ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // Get Windows SDK installation directory. 4076cd5216bb61e6165d8f6e8fb781d45c035bd4e00Benjamin Kramerstatic bool getWindowsSDKDir(std::string &path) { 40875ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson char windowsSDKInstallDir[256]; 40975ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // Try the Windows registry. 41075ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson bool hasSDKDir = getSystemRegistryString( 41175ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\$VERSION", 412ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner "InstallationFolder", 413ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner windowsSDKInstallDir, 414ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner sizeof(windowsSDKInstallDir) - 1); 415125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi // If we have both vc80 and vc90, pick version we were compiled with. 41675ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson if (hasSDKDir && windowsSDKInstallDir[0]) { 41775ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson path = windowsSDKInstallDir; 41875ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson return(true); 41975ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson } 42075ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson return(false); 42175ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson} 42275ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson 42379bc57c074cb91f574fba19215f95b63dcf6b04bmike-mvoid InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple, 42479bc57c074cb91f574fba19215f95b63dcf6b04bmike-m const HeaderSearchOptions &HSOpts) { 4258e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer llvm::Triple::OSType os = triple.getOS(); 4268e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer 4278e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer switch (os) { 428630766057eabe78f9bb2e0c0d023223fb8d0174eRoman Divacky case llvm::Triple::FreeBSD: 4298e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer case llvm::Triple::NetBSD: 4308e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer break; 4318e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer default: 4328e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer // FIXME: temporary hack: hard-coded paths. 4338e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer AddPath("/usr/local/include", System, true, false, false); 4348e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer break; 4358e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer } 43679bc57c074cb91f574fba19215f95b63dcf6b04bmike-m 43779bc57c074cb91f574fba19215f95b63dcf6b04bmike-m // Builtin includes use #include_next directives and should be positioned 43879bc57c074cb91f574fba19215f95b63dcf6b04bmike-m // just prior C include dirs. 43979bc57c074cb91f574fba19215f95b63dcf6b04bmike-m if (HSOpts.UseBuiltinIncludes) { 44079bc57c074cb91f574fba19215f95b63dcf6b04bmike-m // Ignore the sys root, we *always* look for clang headers relative to 44179bc57c074cb91f574fba19215f95b63dcf6b04bmike-m // supplied path. 44279bc57c074cb91f574fba19215f95b63dcf6b04bmike-m llvm::sys::Path P(HSOpts.ResourceDir); 44379bc57c074cb91f574fba19215f95b63dcf6b04bmike-m P.appendComponent("include"); 44479bc57c074cb91f574fba19215f95b63dcf6b04bmike-m AddPath(P.str(), System, false, false, false, /*IgnoreSysRoot=*/ true); 44579bc57c074cb91f574fba19215f95b63dcf6b04bmike-m } 44679bc57c074cb91f574fba19215f95b63dcf6b04bmike-m 44779bc57c074cb91f574fba19215f95b63dcf6b04bmike-m // Add dirs specified via 'configure --with-c-include-dirs'. 4485f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner StringRef CIncludeDirs(C_INCLUDE_DIRS); 449c706468b1e00bab49ca92eb500a39657f530f828Daniel Dunbar if (CIncludeDirs != "") { 4505f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner SmallVector<StringRef, 5> dirs; 451aadd7a48453b4f58bd8e1e9eb670918ee7d6a711Rafael Espindola CIncludeDirs.split(dirs, ":"); 4525f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner for (SmallVectorImpl<StringRef>::iterator i = dirs.begin(); 453aadd7a48453b4f58bd8e1e9eb670918ee7d6a711Rafael Espindola i != dirs.end(); 454125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi ++i) 455f0a2f51be576089e1a84cd677c09156dae067b6aRafael Espindola AddPath(*i, System, false, false, false); 456f0a2f51be576089e1a84cd677c09156dae067b6aRafael Espindola return; 457f0a2f51be576089e1a84cd677c09156dae067b6aRafael Espindola } 4588e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer 45943d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump switch (os) { 460d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar case llvm::Triple::Win32: { 461d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar std::string VSDir; 462d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar std::string WindowsSDKDir; 463d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar if (getVisualStudioDir(VSDir)) { 464d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar AddPath(VSDir + "\\VC\\include", System, false, false, false); 465d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar if (getWindowsSDKDir(WindowsSDKDir)) 466d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar AddPath(WindowsSDKDir + "\\include", System, false, false, false); 467d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar else 468d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar AddPath(VSDir + "\\VC\\PlatformSDK\\Include", 469d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar System, false, false, false); 470d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar } else { 471d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar // Default install paths. 472d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar AddPath("C:/Program Files/Microsoft Visual Studio 10.0/VC/include", 473d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar System, false, false, false); 474d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar AddPath("C:/Program Files/Microsoft Visual Studio 9.0/VC/include", 475d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar System, false, false, false); 476d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar AddPath( 4779319f02dea2449caf5c7a0d07c596ca324e43574John Thompson "C:/Program Files/Microsoft Visual Studio 9.0/VC/PlatformSDK/Include", 478d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar System, false, false, false); 479d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar AddPath("C:/Program Files/Microsoft Visual Studio 8/VC/include", 480d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar System, false, false, false); 481d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar AddPath( 4829319f02dea2449caf5c7a0d07c596ca324e43574John Thompson "C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/Include", 483d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar System, false, false, false); 48443d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump } 48543d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump break; 486d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar } 48786ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner case llvm::Triple::Haiku: 48886ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/common/include", System, true, false, false); 48986ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os", System, true, false, false); 49086ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/app", System, true, false, false); 49186ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/arch", System, true, false, false); 49286ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/device", System, true, false, false); 49386ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/drivers", System, true, false, false); 494125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi AddPath("/boot/develop/headers/os/game", System, true, false, false); 49586ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/interface", System, true, false, false); 49686ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/kernel", System, true, false, false); 49786ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/locale", System, true, false, false); 49886ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/mail", System, true, false, false); 49986ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/media", System, true, false, false); 50086ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/midi", System, true, false, false); 50186ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/midi2", System, true, false, false); 50286ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/net", System, true, false, false); 50386ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/storage", System, true, false, false); 50486ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/support", System, true, false, false); 50586ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/translation", 50686ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner System, true, false, false); 507125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi AddPath("/boot/develop/headers/os/add-ons/graphics", 50886ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner System, true, false, false); 509125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi AddPath("/boot/develop/headers/os/add-ons/input_server", 51086ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner System, true, false, false); 511125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi AddPath("/boot/develop/headers/os/add-ons/screen_saver", 51286ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner System, true, false, false); 513125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi AddPath("/boot/develop/headers/os/add-ons/tracker", 51486ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner System, true, false, false); 51586ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/be_apps/Deskbar", 51686ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner System, true, false, false); 51786ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/be_apps/NetPositive", 51886ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner System, true, false, false); 51986ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/be_apps/Tracker", 52086ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner System, true, false, false); 52186ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/cpp", System, true, false, false); 522125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi AddPath("/boot/develop/headers/cpp/i586-pc-haiku", 52386ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner System, true, false, false); 52486ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/3rdparty", System, true, false, false); 52586ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/bsd", System, true, false, false); 52686ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/glibc", System, true, false, false); 52786ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/posix", System, true, false, false); 52886ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers", System, true, false, false); 529a7e6845660f91ec611427e1db842780e1ec12bdbEli Friedman break; 530dca5226598097add5d86d57b227aa31df27f0ba4Douglas Gregor case llvm::Triple::RTEMS: 531dca5226598097add5d86d57b227aa31df27f0ba4Douglas Gregor break; 53232df002017e3e8d86bfd3f7090b341d265676fc9NAKAMURA Takumi case llvm::Triple::Cygwin: 53332df002017e3e8d86bfd3f7090b341d265676fc9NAKAMURA Takumi AddPath("/usr/include/w32api", System, true, false, false); 53432df002017e3e8d86bfd3f7090b341d265676fc9NAKAMURA Takumi break; 535d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor case llvm::Triple::MinGW32: { 536d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor // mingw-w64 crt include paths 537d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor llvm::sys::Path P(HSOpts.ResourceDir); 538d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor P.appendComponent("../../../i686-w64-mingw32/include"); // <sysroot>/i686-w64-mingw32/include 539d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddPath(P.str(), System, true, false, false); 540d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor P = llvm::sys::Path(HSOpts.ResourceDir); 541d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor P.appendComponent("../../../x86_64-w64-mingw32/include"); // <sysroot>/x86_64-w64-mingw32/include 542d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddPath(P.str(), System, true, false, false); 543d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor // mingw.org crt include paths 544d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor P = llvm::sys::Path(HSOpts.ResourceDir); 545d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor P.appendComponent("../../../include"); // <sysroot>/include 546d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddPath(P.str(), System, true, false, false); 547d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddPath("/mingw/include", System, true, false, false); 548d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddPath("c:/mingw/include", System, true, false, false); 549d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor } 55043d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump break; 551d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor 552b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher case llvm::Triple::Linux: 553b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher // Generic Debian multiarch support: 554b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher if (triple.getArch() == llvm::Triple::x86_64) { 555b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher AddPath("/usr/include/x86_64-linux-gnu", System, false, false, false); 556b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher AddPath("/usr/include/i686-linux-gnu/64", System, false, false, false); 557b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher AddPath("/usr/include/i486-linux-gnu/64", System, false, false, false); 55855ab5b0799c256a719e69ce463652839135e62f7Eric Christopher } else if (triple.getArch() == llvm::Triple::x86) { 559b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher AddPath("/usr/include/x86_64-linux-gnu/32", System, false, false, false); 560b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher AddPath("/usr/include/i686-linux-gnu", System, false, false, false); 561b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher AddPath("/usr/include/i486-linux-gnu", System, false, false, false); 56255ab5b0799c256a719e69ce463652839135e62f7Eric Christopher } else if (triple.getArch() == llvm::Triple::arm) { 56355ab5b0799c256a719e69ce463652839135e62f7Eric Christopher AddPath("/usr/include/arm-linux-gnueabi", System, false, false, false); 564b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher } 56543d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump default: 56643d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump break; 5670fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 568d3f88343af2dec3459493fafa22532317321eaf0John Thompson 569dca5226598097add5d86d57b227aa31df27f0ba4Douglas Gregor if ( os != llvm::Triple::RTEMS ) 570dca5226598097add5d86d57b227aa31df27f0ba4Douglas Gregor AddPath("/usr/include", System, false, false, false); 571e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola} 572e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola 5730e3cc05542e62fe89345ce94a73494525ee463e0Chris Lattnervoid InitHeaderSearch:: 574d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas GregorAddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple, const HeaderSearchOptions &HSOpts) { 575e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola llvm::Triple::OSType os = triple.getOS(); 5765f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner StringRef CxxIncludeRoot(CXX_INCLUDE_ROOT); 577ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola if (CxxIncludeRoot != "") { 5785f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner StringRef CxxIncludeArch(CXX_INCLUDE_ARCH); 579ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola if (CxxIncludeArch == "") 580ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola AddGnuCPlusPlusIncludePaths(CxxIncludeRoot, triple.str().c_str(), 5810e3cc05542e62fe89345ce94a73494525ee463e0Chris Lattner CXX_INCLUDE_32BIT_DIR, CXX_INCLUDE_64BIT_DIR, 5820e3cc05542e62fe89345ce94a73494525ee463e0Chris Lattner triple); 583ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola else 584ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola AddGnuCPlusPlusIncludePaths(CxxIncludeRoot, CXX_INCLUDE_ARCH, 5850e3cc05542e62fe89345ce94a73494525ee463e0Chris Lattner CXX_INCLUDE_32BIT_DIR, CXX_INCLUDE_64BIT_DIR, 5860e3cc05542e62fe89345ce94a73494525ee463e0Chris Lattner triple); 587ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola return; 588ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola } 589e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola // FIXME: temporary hack: hard-coded paths. 590db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar 591db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar if (triple.isOSDarwin()) { 592f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar switch (triple.getArch()) { 593f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar default: break; 594f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar 595125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi case llvm::Triple::ppc: 596582c30135dce1857db62e58b916ab0fa5edfb1d6Douglas Gregor case llvm::Triple::ppc64: 597616d4362f01a8f819f9351372c3c4368777d4480Douglas Gregor AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1", 598125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi "powerpc-apple-darwin10", "", "ppc64", 599616d4362f01a8f819f9351372c3c4368777d4480Douglas Gregor triple); 600582c30135dce1857db62e58b916ab0fa5edfb1d6Douglas Gregor AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.0.0", 601125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi "powerpc-apple-darwin10", "", "ppc64", 602582c30135dce1857db62e58b916ab0fa5edfb1d6Douglas Gregor triple); 603582c30135dce1857db62e58b916ab0fa5edfb1d6Douglas Gregor break; 604582c30135dce1857db62e58b916ab0fa5edfb1d6Douglas Gregor 605f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar case llvm::Triple::x86: 606f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar case llvm::Triple::x86_64: 607f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1", 608f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar "i686-apple-darwin10", "", "x86_64", triple); 609f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.0.0", 610f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar "i686-apple-darwin8", "", "", triple); 611f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar break; 612f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar 613f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar case llvm::Triple::arm: 614f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar case llvm::Triple::thumb: 615f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1", 616f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar "arm-apple-darwin10", "v7", "", triple); 617f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1", 618f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar "arm-apple-darwin10", "v6", "", triple); 619f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar break; 620f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar } 621db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar return; 622db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar } 623db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar 624db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar switch (os) { 625db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar case llvm::Triple::Cygwin: 626db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar // Cygwin-1.7 627db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "4.3.4"); 628db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar // g++-4 / Cygwin-1.5 629db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "4.3.2"); 630db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar // FIXME: Do we support g++-3.4.4? 631db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "3.4.4"); 632db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar break; 633db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar case llvm::Triple::MinGW32: 634d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor // mingw-w64 C++ include paths (i686-w64-mingw32 and x86_64-w64-mingw32) 635d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddMinGW64CXXPaths(HSOpts.ResourceDir, "4.5.0"); 636d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddMinGW64CXXPaths(HSOpts.ResourceDir, "4.5.1"); 637d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddMinGW64CXXPaths(HSOpts.ResourceDir, "4.5.2"); 638d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddMinGW64CXXPaths(HSOpts.ResourceDir, "4.5.3"); 639d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddMinGW64CXXPaths(HSOpts.ResourceDir, "4.6.0"); 640d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddMinGW64CXXPaths(HSOpts.ResourceDir, "4.6.1"); 641f732f2b11b136f34aecb95b0a2e72f5f272eb723Douglas Gregor AddMinGW64CXXPaths(HSOpts.ResourceDir, "4.6.2"); 642f732f2b11b136f34aecb95b0a2e72f5f272eb723Douglas Gregor AddMinGW64CXXPaths(HSOpts.ResourceDir, "4.7.0"); 643d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor // mingw.org C++ include paths 644d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddMinGWCPlusPlusIncludePaths("/mingw/lib/gcc", "mingw32", "4.5.2"); //MSYS 645db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", "mingw32", "4.5.0"); 646db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", "mingw32", "4.4.0"); 647db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", "mingw32", "4.3.0"); 648e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola break; 6497a7ca281bcf50b34de1ce067d3c55879b81722aeChris Lattner case llvm::Triple::DragonFly: 6502df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger AddPath("/usr/include/c++/4.1", CXXSystem, true, false, false); 6517a7ca281bcf50b34de1ce067d3c55879b81722aeChris Lattner break; 652e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola case llvm::Triple::Linux: 653ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m //===------------------------------------------------------------------===// 654ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Debian based distros. 655ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Note: these distros symlink /usr/include/c++/X.Y.Z -> X.Y 656ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m //===------------------------------------------------------------------===// 657b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher 658b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher // Ubuntu 11.11 "Oneiric Ocelot" -- gcc-4.6.0 659b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6", 660b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher "x86_64-linux-gnu", "32", "", triple); 661b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6", 662b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher "i686-linux-gnu", "", "64", triple); 663b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6", 664b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher "i486-linux-gnu", "", "64", triple); 665b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6", 666b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher "arm-linux-gnueabi", "", "", triple); 667b3169da1e57f5feb53f4a0396bd8e7ec70309980Eric Christopher 66814a011688d52794cf58fec8197e4518a54f03d80Axel Naumann // Ubuntu 11.04 "Natty Narwhal" -- gcc-4.5.2 66914a011688d52794cf58fec8197e4518a54f03d80Axel Naumann AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5", 67014a011688d52794cf58fec8197e4518a54f03d80Axel Naumann "x86_64-linux-gnu", "32", "", triple); 67114a011688d52794cf58fec8197e4518a54f03d80Axel Naumann AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5", 67214a011688d52794cf58fec8197e4518a54f03d80Axel Naumann "i686-linux-gnu", "", "64", triple); 67314a011688d52794cf58fec8197e4518a54f03d80Axel Naumann AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5", 67414a011688d52794cf58fec8197e4518a54f03d80Axel Naumann "i486-linux-gnu", "", "64", triple); 67514a011688d52794cf58fec8197e4518a54f03d80Axel Naumann AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5", 67614a011688d52794cf58fec8197e4518a54f03d80Axel Naumann "arm-linux-gnueabi", "", "", triple); 67714a011688d52794cf58fec8197e4518a54f03d80Axel Naumann 678c12bbe5cbee8936204d286e17d8e0511dd67ddb4Rafael Espindola // Ubuntu 10.10 "Maverick Meerkat" -- gcc-4.4.5 679adafdbae908a8e798fa4940ed89f61597b3d7ca5Rafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4", 680adafdbae908a8e798fa4940ed89f61597b3d7ca5Rafael Espindola "i686-linux-gnu", "", "64", triple); 681adafdbae908a8e798fa4940ed89f61597b3d7ca5Rafael Espindola // The rest of 10.10 is the same as previous versions. 682adafdbae908a8e798fa4940ed89f61597b3d7ca5Rafael Espindola 683ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Ubuntu 10.04 LTS "Lucid Lynx" -- gcc-4.4.3 684ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Ubuntu 9.10 "Karmic Koala" -- gcc-4.4.1 685ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Debian 6.0 "squeeze" -- gcc-4.4.2 686e69f047a6c882ce36bd260a8fed0ae31114a5a7eNick Lewycky AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4", 687331e8010aed1c2175328ed470aea75e93ff70b32Torok Edwin "x86_64-linux-gnu", "32", "", triple); 688e69f047a6c882ce36bd260a8fed0ae31114a5a7eNick Lewycky AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4", 689ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i486-linux-gnu", "", "64", triple); 690db0835552ff4b640bc908a50ccd075ab63cf6fffNick Lewycky AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4", 691db0835552ff4b640bc908a50ccd075ab63cf6fffNick Lewycky "arm-linux-gnueabi", "", "", triple); 692ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Ubuntu 9.04 "Jaunty Jackalope" -- gcc-4.3.3 693ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Ubuntu 8.10 "Intrepid Ibex" -- gcc-4.3.2 694ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Debian 5.0 "lenny" -- gcc-4.3.2 695ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3", 696ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "x86_64-linux-gnu", "32", "", triple); 697ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3", 698ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i486-linux-gnu", "", "64", triple); 699e7d6c2cae6a9b9985db02cfc8bb4e7b714630ed5Rafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3", 700e7d6c2cae6a9b9985db02cfc8bb4e7b714630ed5Rafael Espindola "arm-linux-gnueabi", "", "", triple); 701ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Ubuntu 8.04.4 LTS "Hardy Heron" -- gcc-4.2.4 702ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Ubuntu 8.04.[0-3] LTS "Hardy Heron" -- gcc-4.2.3 703ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2", 704ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "x86_64-linux-gnu", "32", "", triple); 705ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2", 706ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i486-linux-gnu", "", "64", triple); 707ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Ubuntu 7.10 "Gutsy Gibbon" -- gcc-4.1.3 708ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1", 709ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "x86_64-linux-gnu", "32", "", triple); 710ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1", 711ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i486-linux-gnu", "", "64", triple); 712189a14869a36ecf8bd5edc94255a34061044efe2Nuno Lopes 713ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m //===------------------------------------------------------------------===// 714ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Redhat based distros. 715ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m //===------------------------------------------------------------------===// 716ef48e053f98391d3df2818307160de16988227a5Justin Holewinski // Fedora 15 (GCC 4.6.1) 717ef48e053f98391d3df2818307160de16988227a5Justin Holewinski AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.1", 718ef48e053f98391d3df2818307160de16988227a5Justin Holewinski "x86_64-redhat-linux", "32", "", triple); 719ef48e053f98391d3df2818307160de16988227a5Justin Holewinski AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.1", 720ef48e053f98391d3df2818307160de16988227a5Justin Holewinski "i686-redhat-linux", "", "", triple); 721ef48e053f98391d3df2818307160de16988227a5Justin Holewinski // Fedora 15 (GCC 4.6.0) 7228f1cc075c36212797ef52dac0e2fe35417a6bb6bEric Christopher AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.0", 7238f1cc075c36212797ef52dac0e2fe35417a6bb6bEric Christopher "x86_64-redhat-linux", "32", "", triple); 7248f1cc075c36212797ef52dac0e2fe35417a6bb6bEric Christopher AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.0", 7258f1cc075c36212797ef52dac0e2fe35417a6bb6bEric Christopher "i686-redhat-linux", "", "", triple); 7266638b3a15edea25c4b1fdf8046e71d82683d8efaRafael Espindola // Fedora 14 7276638b3a15edea25c4b1fdf8046e71d82683d8efaRafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5.1", 7286638b3a15edea25c4b1fdf8046e71d82683d8efaRafael Espindola "x86_64-redhat-linux", "32", "", triple); 7296638b3a15edea25c4b1fdf8046e71d82683d8efaRafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5.1", 7306638b3a15edea25c4b1fdf8046e71d82683d8efaRafael Espindola "i686-redhat-linux", "", "", triple); 731c37039803a18c7f0f0975a618147d336de3d3d58NAKAMURA Takumi // RHEL5(gcc44) 732c37039803a18c7f0f0975a618147d336de3d3d58NAKAMURA Takumi AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.4", 733c37039803a18c7f0f0975a618147d336de3d3d58NAKAMURA Takumi "x86_64-redhat-linux6E", "32", "", triple); 734ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Fedora 13 7354336e191cc52aa1ef72f9a542f5a6d5f9f02a825Chris Lattner AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.4", 7364336e191cc52aa1ef72f9a542f5a6d5f9f02a825Chris Lattner "x86_64-redhat-linux", "32", "", triple); 7374336e191cc52aa1ef72f9a542f5a6d5f9f02a825Chris Lattner AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.4", 7384336e191cc52aa1ef72f9a542f5a6d5f9f02a825Chris Lattner "i686-redhat-linux","", "", triple); 739ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Fedora 12 740ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.3", 7410720b5159010479c08f8264a8a209037ecf55922Chris Lattner "x86_64-redhat-linux", "32", "", triple); 742ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.3", 743ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i686-redhat-linux","", "", triple); 744ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Fedora 12 (pre-FEB-2010) 745ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.2", 746ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "x86_64-redhat-linux", "32", "", triple); 747ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.2", 748ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i686-redhat-linux","", "", triple); 749189a14869a36ecf8bd5edc94255a34061044efe2Nuno Lopes // Fedora 11 750189a14869a36ecf8bd5edc94255a34061044efe2Nuno Lopes AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.1", 751ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "x86_64-redhat-linux", "32", "", triple); 752ea00f847a0e1771b1fcfe683d3506940dc2de1ecChris Lattner AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.1", 753ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i586-redhat-linux","", "", triple); 754ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Fedora 10 755ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.2", 756ea00f847a0e1771b1fcfe683d3506940dc2de1ecChris Lattner "x86_64-redhat-linux", "32", "", triple); 757ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.2", 758ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i386-redhat-linux","", "", triple); 759ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Fedora 9 760ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.0", 761ea00f847a0e1771b1fcfe683d3506940dc2de1ecChris Lattner "x86_64-redhat-linux", "32", "", triple); 762ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.0", 763ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i386-redhat-linux", "", "", triple); 764ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Fedora 8 765ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1.2", 766ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "x86_64-redhat-linux", "", "", triple); 767ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1.2", 768ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i386-redhat-linux", "", "", triple); 769199e09a93813516a5e8f9ce2c3cd4c18d60961dbEric Christopher 770199e09a93813516a5e8f9ce2c3cd4c18d60961dbEric Christopher // RHEL 5 771199e09a93813516a5e8f9ce2c3cd4c18d60961dbEric Christopher AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1.1", 772199e09a93813516a5e8f9ce2c3cd4c18d60961dbEric Christopher "x86_64-redhat-linux", "32", "", triple); 773199e09a93813516a5e8f9ce2c3cd4c18d60961dbEric Christopher AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1.1", 774199e09a93813516a5e8f9ce2c3cd4c18d60961dbEric Christopher "i386-redhat-linux", "", "", triple); 775199e09a93813516a5e8f9ce2c3cd4c18d60961dbEric Christopher 776ea00f847a0e1771b1fcfe683d3506940dc2de1ecChris Lattner 777ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m //===------------------------------------------------------------------===// 778ea00f847a0e1771b1fcfe683d3506940dc2de1ecChris Lattner 779ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Exherbo (2010-01-25) 780ea00f847a0e1771b1fcfe683d3506940dc2de1ecChris Lattner AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.3", 781ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "x86_64-pc-linux-gnu", "32", "", triple); 782ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.3", 783ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i686-pc-linux-gnu", "", "", triple); 784ea00f847a0e1771b1fcfe683d3506940dc2de1ecChris Lattner 785e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola // openSUSE 11.1 32 bit 786e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3", 787ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "i586-suse-linux", "", "", triple); 788e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola // openSUSE 11.1 64 bit 789e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3", 790ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "x86_64-suse-linux", "32", "", triple); 791e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola // openSUSE 11.2 792e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4", 793ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "i586-suse-linux", "", "", triple); 794e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4", 795ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "x86_64-suse-linux", "", "", triple); 7969d2c06001b0c09fdb0f973cd6f8fa5555aea1b5fRafael Espindola 7979d2c06001b0c09fdb0f973cd6f8fa5555aea1b5fRafael Espindola // openSUSE 11.4 7989d2c06001b0c09fdb0f973cd6f8fa5555aea1b5fRafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5", 7999d2c06001b0c09fdb0f973cd6f8fa5555aea1b5fRafael Espindola "i586-suse-linux", "", "", triple); 8009d2c06001b0c09fdb0f973cd6f8fa5555aea1b5fRafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5", 8019d2c06001b0c09fdb0f973cd6f8fa5555aea1b5fRafael Espindola "x86_64-suse-linux", "", "", triple); 8029d2c06001b0c09fdb0f973cd6f8fa5555aea1b5fRafael Espindola 8032eb3cce91fa334be35caefedd5374c22d086ad1cDavid Chisnall // openSUSE 12.1 8042eb3cce91fa334be35caefedd5374c22d086ad1cDavid Chisnall AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6", 8052eb3cce91fa334be35caefedd5374c22d086ad1cDavid Chisnall "i586-suse-linux", "", "", triple); 8062eb3cce91fa334be35caefedd5374c22d086ad1cDavid Chisnall AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6", 8072eb3cce91fa334be35caefedd5374c22d086ad1cDavid Chisnall "x86_64-suse-linux", "", "", triple); 808e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola // Arch Linux 2008-06-24 809e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.1", 810ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "i686-pc-linux-gnu", "", "", triple); 811e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.1", 812ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "x86_64-unknown-linux-gnu", "", "", triple); 813014f9720bc53cc748aa13b0773cd67428a9e6ae4Nico Weber 814014f9720bc53cc748aa13b0773cd67428a9e6ae4Nico Weber // Arch Linux gcc 4.6 81537187cc4554d34fbbb5f168041d6acc4be028fe9Chandler Carruth AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.1", 81637187cc4554d34fbbb5f168041d6acc4be028fe9Chandler Carruth "i686-pc-linux-gnu", "", "", triple); 81737187cc4554d34fbbb5f168041d6acc4be028fe9Chandler Carruth AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.1", 81837187cc4554d34fbbb5f168041d6acc4be028fe9Chandler Carruth "x86_64-unknown-linux-gnu", "", "", triple); 819014f9720bc53cc748aa13b0773cd67428a9e6ae4Nico Weber AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.0", 820014f9720bc53cc748aa13b0773cd67428a9e6ae4Nico Weber "i686-pc-linux-gnu", "", "", triple); 821014f9720bc53cc748aa13b0773cd67428a9e6ae4Nico Weber AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.0", 822014f9720bc53cc748aa13b0773cd67428a9e6ae4Nico Weber "x86_64-unknown-linux-gnu", "", "", triple); 823014f9720bc53cc748aa13b0773cd67428a9e6ae4Nico Weber 824b1f2f4782097ed5e0a760598cbb853864cf9d7ceEli Friedman // Slackware gcc 4.5.2 (13.37) 825b1f2f4782097ed5e0a760598cbb853864cf9d7ceEli Friedman AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5.2", 826b1f2f4782097ed5e0a760598cbb853864cf9d7ceEli Friedman "i486-slackware-linux", "", "", triple); 827b1f2f4782097ed5e0a760598cbb853864cf9d7ceEli Friedman AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5.2", 828b1f2f4782097ed5e0a760598cbb853864cf9d7ceEli Friedman "x86_64-slackware-linux", "", "", triple); 829b1f2f4782097ed5e0a760598cbb853864cf9d7ceEli Friedman // Slackware gcc 4.5.3 (-current) 830b1f2f4782097ed5e0a760598cbb853864cf9d7ceEli Friedman AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5.3", 831b1f2f4782097ed5e0a760598cbb853864cf9d7ceEli Friedman "i486-slackware-linux", "", "", triple); 832b1f2f4782097ed5e0a760598cbb853864cf9d7ceEli Friedman AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5.3", 833b1f2f4782097ed5e0a760598cbb853864cf9d7ceEli Friedman "x86_64-slackware-linux", "", "", triple); 834b1f2f4782097ed5e0a760598cbb853864cf9d7ceEli Friedman 8355370383567e32c840b728bd5d066db281710f2c1Douglas Gregor // Gentoo x86 gcc 4.5.2 8365370383567e32c840b728bd5d066db281710f2c1Douglas Gregor AddGnuCPlusPlusIncludePaths( 8375370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/g++-v4", 8385370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "i686-pc-linux-gnu", "", "", triple); 8395370383567e32c840b728bd5d066db281710f2c1Douglas Gregor // Gentoo x86 gcc 4.4.5 8405370383567e32c840b728bd5d066db281710f2c1Douglas Gregor AddGnuCPlusPlusIncludePaths( 8415370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "/usr/lib/gcc/i686-pc-linux-gnu/4.4.5/include/g++-v4", 8425370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "i686-pc-linux-gnu", "", "", triple); 8435370383567e32c840b728bd5d066db281710f2c1Douglas Gregor // Gentoo x86 gcc 4.4.4 8445370383567e32c840b728bd5d066db281710f2c1Douglas Gregor AddGnuCPlusPlusIncludePaths( 8455370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "/usr/lib/gcc/i686-pc-linux-gnu/4.4.4/include/g++-v4", 8465370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "i686-pc-linux-gnu", "", "", triple); 8475370383567e32c840b728bd5d066db281710f2c1Douglas Gregor // Gentoo x86 2010.0 stable 8480d155a5e1d6406d27df5779d0c9fb98d49a713a0Nuno Lopes AddGnuCPlusPlusIncludePaths( 8490d155a5e1d6406d27df5779d0c9fb98d49a713a0Nuno Lopes "/usr/lib/gcc/i686-pc-linux-gnu/4.4.3/include/g++-v4", 8500d155a5e1d6406d27df5779d0c9fb98d49a713a0Nuno Lopes "i686-pc-linux-gnu", "", "", triple); 851e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola // Gentoo x86 2009.1 stable 852e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths( 85340d1bb6383c14d5f8249d0640e8088a91b694c66John Thompson "/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4", 854ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "i686-pc-linux-gnu", "", "", triple); 855e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola // Gentoo x86 2009.0 stable 856e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths( 85740d1bb6383c14d5f8249d0640e8088a91b694c66John Thompson "/usr/lib/gcc/i686-pc-linux-gnu/4.3.2/include/g++-v4", 858ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "i686-pc-linux-gnu", "", "", triple); 859e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola // Gentoo x86 2008.0 stable 860e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths( 86140d1bb6383c14d5f8249d0640e8088a91b694c66John Thompson "/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4", 862ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "i686-pc-linux-gnu", "", "", triple); 8635370383567e32c840b728bd5d066db281710f2c1Douglas Gregor // Gentoo x86 llvm-gcc trunk 8645370383567e32c840b728bd5d066db281710f2c1Douglas Gregor AddGnuCPlusPlusIncludePaths( 8655370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "/usr/lib/llvm-gcc-4.2-9999/include/c++/4.2.1", 8665370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "i686-pc-linux-gnu", "", "", triple); 867fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth 8685370383567e32c840b728bd5d066db281710f2c1Douglas Gregor // Gentoo amd64 gcc 4.5.2 8695370383567e32c840b728bd5d066db281710f2c1Douglas Gregor AddGnuCPlusPlusIncludePaths( 8705370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/include/g++-v4", 8715370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "x86_64-pc-linux-gnu", "32", "", triple); 872fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth // Gentoo amd64 gcc 4.4.5 873e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths( 874fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth "/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.5/include/g++-v4", 875fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth "x86_64-pc-linux-gnu", "32", "", triple); 876fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth // Gentoo amd64 gcc 4.4.4 87770d9d4196e6531926ca18b2ca850eb218041488dEric Christopher AddGnuCPlusPlusIncludePaths( 878fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth "/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.4/include/g++-v4", 879fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth "x86_64-pc-linux-gnu", "32", "", triple); 88070d9d4196e6531926ca18b2ca850eb218041488dEric Christopher // Gentoo amd64 gcc 4.4.3 88170d9d4196e6531926ca18b2ca850eb218041488dEric Christopher AddGnuCPlusPlusIncludePaths( 88270d9d4196e6531926ca18b2ca850eb218041488dEric Christopher "/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.3/include/g++-v4", 88370d9d4196e6531926ca18b2ca850eb218041488dEric Christopher "x86_64-pc-linux-gnu", "32", "", triple); 884236a537eacbb347b5aa19a8aa2c82cdb7da8a62bNico Weber // Gentoo amd64 gcc 4.3.4 885236a537eacbb347b5aa19a8aa2c82cdb7da8a62bNico Weber AddGnuCPlusPlusIncludePaths( 886236a537eacbb347b5aa19a8aa2c82cdb7da8a62bNico Weber "/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.4/include/g++-v4", 887236a537eacbb347b5aa19a8aa2c82cdb7da8a62bNico Weber "x86_64-pc-linux-gnu", "", "", triple); 888fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth // Gentoo amd64 gcc 4.3.2 8898ad8a1cc1e39d70345d45ef1b8564ec6cbf49471Nico Weber AddGnuCPlusPlusIncludePaths( 890fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth "/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/include/g++-v4", 891fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth "x86_64-pc-linux-gnu", "", "", triple); 892fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth // Gentoo amd64 stable 893fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth AddGnuCPlusPlusIncludePaths( 894fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth "/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/include/g++-v4", 8955370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "x86_64-pc-linux-gnu", "", "", triple); 8968ad8a1cc1e39d70345d45ef1b8564ec6cbf49471Nico Weber 8976693534adb31fdd13b1ee873df3e90c99f916ad5Nick Lewycky // Gentoo amd64 llvm-gcc trunk 8986693534adb31fdd13b1ee873df3e90c99f916ad5Nick Lewycky AddGnuCPlusPlusIncludePaths( 8996693534adb31fdd13b1ee873df3e90c99f916ad5Nick Lewycky "/usr/lib/llvm-gcc-4.2-9999/include/c++/4.2.1", 9006693534adb31fdd13b1ee873df3e90c99f916ad5Nick Lewycky "x86_64-pc-linux-gnu", "", "", triple); 901fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth 902e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola break; 903e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola case llvm::Triple::FreeBSD: 904ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // FreeBSD 8.0 905ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // FreeBSD 7.3 906afe859a9a6217f177daf42ebab294a90bfe8a6abNuno Lopes AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2", "", "", "", triple); 907e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola break; 908ab079419ff2e52652be349e949202a2470f8d253Anton Korobeynikov case llvm::Triple::NetBSD: 909ab079419ff2e52652be349e949202a2470f8d253Anton Korobeynikov AddGnuCPlusPlusIncludePaths("/usr/include/g++", "", "", "", triple); 910ab079419ff2e52652be349e949202a2470f8d253Anton Korobeynikov break; 91195c0457054518102af6250e718a13a5b2ee5dbeaDaniel Dunbar case llvm::Triple::OpenBSD: { 91295c0457054518102af6250e718a13a5b2ee5dbeaDaniel Dunbar std::string t = triple.getTriple(); 91395c0457054518102af6250e718a13a5b2ee5dbeaDaniel Dunbar if (t.substr(0, 6) == "x86_64") 91495c0457054518102af6250e718a13a5b2ee5dbeaDaniel Dunbar t.replace(0, 6, "amd64"); 91595c0457054518102af6250e718a13a5b2ee5dbeaDaniel Dunbar AddGnuCPlusPlusIncludePaths("/usr/include/g++", 91695c0457054518102af6250e718a13a5b2ee5dbeaDaniel Dunbar t, "", "", triple); 91795c0457054518102af6250e718a13a5b2ee5dbeaDaniel Dunbar break; 91895c0457054518102af6250e718a13a5b2ee5dbeaDaniel Dunbar } 91938e317d6dce161b249508686cc67eb7176958762Chris Lattner case llvm::Triple::Minix: 92038e317d6dce161b249508686cc67eb7176958762Chris Lattner AddGnuCPlusPlusIncludePaths("/usr/gnu/include/c++/4.4.3", 92138e317d6dce161b249508686cc67eb7176958762Chris Lattner "", "", "", triple); 92238e317d6dce161b249508686cc67eb7176958762Chris Lattner break; 923e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola case llvm::Triple::Solaris: 924e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola // Solaris - Fall though.. 925e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola case llvm::Triple::AuroraUX: 926e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola // AuroraUX 927e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths("/opt/gcc4/include/c++/4.2.4", 928ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "i386-pc-solaris2.11", "", "", triple); 929e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola break; 930e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola default: 931e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola break; 932e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola } 933e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola} 934e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola 935e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindolavoid InitHeaderSearch::AddDefaultSystemIncludePaths(const LangOptions &Lang, 9364c2bcad7b843c10fd4a2ffd43da40bfefb4dc8baDouglas Gregor const llvm::Triple &triple, 93779bc57c074cb91f574fba19215f95b63dcf6b04bmike-m const HeaderSearchOptions &HSOpts) { 93813c4f2144b35bda21746eb60ad90e52a9bd8dcdaBob Wilson if (Lang.CPlusPlus && HSOpts.UseStandardCXXIncludes) { 939baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor if (HSOpts.UseLibcxx) { 940baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor if (triple.isOSDarwin()) { 941baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor // On Darwin, libc++ may be installed alongside the compiler in 942baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor // lib/c++/v1. 943baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor llvm::sys::Path P(HSOpts.ResourceDir); 944baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor if (!P.isEmpty()) { 945baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor P.eraseComponent(); // Remove version from foo/lib/clang/version 946baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor P.eraseComponent(); // Remove clang from foo/lib/clang 947baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor 948baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor // Get foo/lib/c++/v1 949baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor P.appendComponent("c++"); 950baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor P.appendComponent("v1"); 951baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor AddPath(P.str(), CXXSystem, true, false, false, true); 952baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor } 953baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor } 954baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor 95513c4f2144b35bda21746eb60ad90e52a9bd8dcdaBob Wilson AddPath("/usr/include/c++/v1", CXXSystem, true, false, false); 956baf41f16421a10c8ecd015baa686aa1b965ae5e3Douglas Gregor } 95713c4f2144b35bda21746eb60ad90e52a9bd8dcdaBob Wilson else 958d944a9b7a680be2ce74aa9398e0604fdebf0338aDouglas Gregor AddDefaultCPlusPlusIncludePaths(triple, HSOpts); 95913c4f2144b35bda21746eb60ad90e52a9bd8dcdaBob Wilson } 9606ec18a3f86c702004af66cce6ff979999a736898Rafael Espindola 96179bc57c074cb91f574fba19215f95b63dcf6b04bmike-m AddDefaultCIncludePaths(triple, HSOpts); 962e166582f8f36f4db8f4ea157538fab7fe6bf2658Daniel Dunbar 963e166582f8f36f4db8f4ea157538fab7fe6bf2658Daniel Dunbar // Add the default framework include paths on Darwin. 964db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar if (triple.isOSDarwin()) { 965e166582f8f36f4db8f4ea157538fab7fe6bf2658Daniel Dunbar AddPath("/System/Library/Frameworks", System, true, false, true); 966e166582f8f36f4db8f4ea157538fab7fe6bf2658Daniel Dunbar AddPath("/Library/Frameworks", System, true, false, true); 967e166582f8f36f4db8f4ea157538fab7fe6bf2658Daniel Dunbar } 968e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola} 969e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola 9700fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber/// RemoveDuplicates - If there are duplicate directory entries in the specified 971e305e81f65d13e6953f623a6b31176ad7041ba20Chad Rosier/// search list, remove the later (dead) ones. Returns the number of non-system 972e305e81f65d13e6953f623a6b31176ad7041ba20Chad Rosier/// headers removed, which is used to update NumAngled. 973e305e81f65d13e6953f623a6b31176ad7041ba20Chad Rosierstatic unsigned RemoveDuplicates(std::vector<DirectoryLookup> &SearchList, 974e305e81f65d13e6953f623a6b31176ad7041ba20Chad Rosier unsigned First, bool Verbose) { 9750fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber llvm::SmallPtrSet<const DirectoryEntry *, 8> SeenDirs; 9760fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber llvm::SmallPtrSet<const DirectoryEntry *, 8> SeenFrameworkDirs; 9770fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber llvm::SmallPtrSet<const HeaderMap *, 8> SeenHeaderMaps; 978e305e81f65d13e6953f623a6b31176ad7041ba20Chad Rosier unsigned NonSystemRemoved = 0; 9792df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger for (unsigned i = First; i != SearchList.size(); ++i) { 9807a739401983eb9bc25c9b4b25177e116f5e5ba92Chris Lattner unsigned DirToRemove = i; 9811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 98243eee07270bf1966ea7289310066aa670c4b647fChris Lattner const DirectoryLookup &CurEntry = SearchList[i]; 9831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 98443eee07270bf1966ea7289310066aa670c4b647fChris Lattner if (CurEntry.isNormalDir()) { 9850fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // If this isn't the first time we've seen this dir, remove it. 98643eee07270bf1966ea7289310066aa670c4b647fChris Lattner if (SeenDirs.insert(CurEntry.getDir())) 9870fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber continue; 98843eee07270bf1966ea7289310066aa670c4b647fChris Lattner } else if (CurEntry.isFramework()) { 9890fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // If this isn't the first time we've seen this framework dir, remove it. 99043eee07270bf1966ea7289310066aa670c4b647fChris Lattner if (SeenFrameworkDirs.insert(CurEntry.getFrameworkDir())) 9910fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber continue; 9920fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } else { 99343eee07270bf1966ea7289310066aa670c4b647fChris Lattner assert(CurEntry.isHeaderMap() && "Not a headermap or normal dir?"); 9940fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // If this isn't the first time we've seen this headermap, remove it. 99543eee07270bf1966ea7289310066aa670c4b647fChris Lattner if (SeenHeaderMaps.insert(CurEntry.getHeaderMap())) 9960fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber continue; 99730f05b553db067c994966daca37e75324ee7b424Chris Lattner } 9981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 99930f05b553db067c994966daca37e75324ee7b424Chris Lattner // If we have a normal #include dir/framework/headermap that is shadowed 100030f05b553db067c994966daca37e75324ee7b424Chris Lattner // later in the chain by a system include location, we actually want to 100130f05b553db067c994966daca37e75324ee7b424Chris Lattner // ignore the user's request and drop the user dir... keeping the system 100230f05b553db067c994966daca37e75324ee7b424Chris Lattner // dir. This is weird, but required to emulate GCC's search path correctly. 100330f05b553db067c994966daca37e75324ee7b424Chris Lattner // 100430f05b553db067c994966daca37e75324ee7b424Chris Lattner // Since dupes of system dirs are rare, just rescan to find the original 100530f05b553db067c994966daca37e75324ee7b424Chris Lattner // that we're nuking instead of using a DenseMap. 100643eee07270bf1966ea7289310066aa670c4b647fChris Lattner if (CurEntry.getDirCharacteristic() != SrcMgr::C_User) { 100730f05b553db067c994966daca37e75324ee7b424Chris Lattner // Find the dir that this is the same of. 100830f05b553db067c994966daca37e75324ee7b424Chris Lattner unsigned FirstDir; 100930f05b553db067c994966daca37e75324ee7b424Chris Lattner for (FirstDir = 0; ; ++FirstDir) { 101030f05b553db067c994966daca37e75324ee7b424Chris Lattner assert(FirstDir != i && "Didn't find dupe?"); 10111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 101243eee07270bf1966ea7289310066aa670c4b647fChris Lattner const DirectoryLookup &SearchEntry = SearchList[FirstDir]; 101343eee07270bf1966ea7289310066aa670c4b647fChris Lattner 101430f05b553db067c994966daca37e75324ee7b424Chris Lattner // If these are different lookup types, then they can't be the dupe. 101543eee07270bf1966ea7289310066aa670c4b647fChris Lattner if (SearchEntry.getLookupType() != CurEntry.getLookupType()) 101630f05b553db067c994966daca37e75324ee7b424Chris Lattner continue; 10171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 101830f05b553db067c994966daca37e75324ee7b424Chris Lattner bool isSame; 101943eee07270bf1966ea7289310066aa670c4b647fChris Lattner if (CurEntry.isNormalDir()) 102043eee07270bf1966ea7289310066aa670c4b647fChris Lattner isSame = SearchEntry.getDir() == CurEntry.getDir(); 102143eee07270bf1966ea7289310066aa670c4b647fChris Lattner else if (CurEntry.isFramework()) 102243eee07270bf1966ea7289310066aa670c4b647fChris Lattner isSame = SearchEntry.getFrameworkDir() == CurEntry.getFrameworkDir(); 102330f05b553db067c994966daca37e75324ee7b424Chris Lattner else { 102443eee07270bf1966ea7289310066aa670c4b647fChris Lattner assert(CurEntry.isHeaderMap() && "Not a headermap or normal dir?"); 102543eee07270bf1966ea7289310066aa670c4b647fChris Lattner isSame = SearchEntry.getHeaderMap() == CurEntry.getHeaderMap(); 102630f05b553db067c994966daca37e75324ee7b424Chris Lattner } 10271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 102830f05b553db067c994966daca37e75324ee7b424Chris Lattner if (isSame) 102930f05b553db067c994966daca37e75324ee7b424Chris Lattner break; 103030f05b553db067c994966daca37e75324ee7b424Chris Lattner } 10311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 103230f05b553db067c994966daca37e75324ee7b424Chris Lattner // If the first dir in the search path is a non-system dir, zap it 103330f05b553db067c994966daca37e75324ee7b424Chris Lattner // instead of the system one. 103430f05b553db067c994966daca37e75324ee7b424Chris Lattner if (SearchList[FirstDir].getDirCharacteristic() == SrcMgr::C_User) 103530f05b553db067c994966daca37e75324ee7b424Chris Lattner DirToRemove = FirstDir; 103630f05b553db067c994966daca37e75324ee7b424Chris Lattner } 103730f05b553db067c994966daca37e75324ee7b424Chris Lattner 103830f05b553db067c994966daca37e75324ee7b424Chris Lattner if (Verbose) { 1039e7cb7e4570842297f698bd7fd8d85520fc008acdDaniel Dunbar llvm::errs() << "ignoring duplicate directory \"" 1040e7cb7e4570842297f698bd7fd8d85520fc008acdDaniel Dunbar << CurEntry.getName() << "\"\n"; 104130f05b553db067c994966daca37e75324ee7b424Chris Lattner if (DirToRemove != i) 1042e7cb7e4570842297f698bd7fd8d85520fc008acdDaniel Dunbar llvm::errs() << " as it is a non-system directory that duplicates " 1043e7cb7e4570842297f698bd7fd8d85520fc008acdDaniel Dunbar << "a system directory\n"; 10440fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 1045e305e81f65d13e6953f623a6b31176ad7041ba20Chad Rosier if (DirToRemove != i) 1046e305e81f65d13e6953f623a6b31176ad7041ba20Chad Rosier ++NonSystemRemoved; 10471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 10487a739401983eb9bc25c9b4b25177e116f5e5ba92Chris Lattner // This is reached if the current entry is a duplicate. Remove the 10497a739401983eb9bc25c9b4b25177e116f5e5ba92Chris Lattner // DirToRemove (usually the current dir). 10507a739401983eb9bc25c9b4b25177e116f5e5ba92Chris Lattner SearchList.erase(SearchList.begin()+DirToRemove); 10510fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber --i; 10520fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 1053e305e81f65d13e6953f623a6b31176ad7041ba20Chad Rosier return NonSystemRemoved; 10540fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber} 10550fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber 10560fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber 10572df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenbergervoid InitHeaderSearch::Realize(const LangOptions &Lang) { 10580fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // Concatenate ANGLE+SYSTEM+AFTER chains together into SearchList. 10590fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber std::vector<DirectoryLookup> SearchList; 10602df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger SearchList.reserve(IncludePath.size()); 10611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1062ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner // Quoted arguments go first. 10632df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger for (path_iterator it = IncludePath.begin(), ie = IncludePath.end(); 10642df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger it != ie; ++it) { 10652df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger if (it->first == Quoted) 10662df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger SearchList.push_back(it->second); 10672df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger } 1068ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner // Deduplicate and remember index. 10692df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger RemoveDuplicates(SearchList, 0, Verbose); 1070ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner unsigned NumQuoted = SearchList.size(); 10712df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger 10722df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger for (path_iterator it = IncludePath.begin(), ie = IncludePath.end(); 10732df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger it != ie; ++it) { 107465e02fa80e1c185f18e5f81cefc30d75383a7301Douglas Gregor if (it->first == Angled || it->first == IndexHeaderMap) 10752df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger SearchList.push_back(it->second); 10762df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger } 1077ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner 1078ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner RemoveDuplicates(SearchList, NumQuoted, Verbose); 1079ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner unsigned NumAngled = SearchList.size(); 10802df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger 10812df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger for (path_iterator it = IncludePath.begin(), ie = IncludePath.end(); 10822df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger it != ie; ++it) { 108347adebef0df6dce752fe9a45e9190e8005b5d07cBenjamin Kramer if (it->first == System || 108447adebef0df6dce752fe9a45e9190e8005b5d07cBenjamin Kramer (!Lang.ObjC1 && !Lang.CPlusPlus && it->first == CSystem) || 1085c535d9730e11ca335790359bfbd4600be71c5410Benjamin Kramer (/*FIXME !Lang.ObjC1 && */Lang.CPlusPlus && it->first == CXXSystem) || 108647adebef0df6dce752fe9a45e9190e8005b5d07cBenjamin Kramer (Lang.ObjC1 && !Lang.CPlusPlus && it->first == ObjCSystem) || 108747adebef0df6dce752fe9a45e9190e8005b5d07cBenjamin Kramer (Lang.ObjC1 && Lang.CPlusPlus && it->first == ObjCXXSystem)) 10882df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger SearchList.push_back(it->second); 10892df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger } 10902df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger 10912df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger for (path_iterator it = IncludePath.begin(), ie = IncludePath.end(); 10922df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger it != ie; ++it) { 10932df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger if (it->first == After) 10942df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger SearchList.push_back(it->second); 10952df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger } 10961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 10971d7f12b83340610f76a73d21cac391e6feced7aaChris Lattner // Remove duplicates across both the Angled and System directories. GCC does 10981d7f12b83340610f76a73d21cac391e6feced7aaChris Lattner // this and failing to remove duplicates across these two groups breaks 10991d7f12b83340610f76a73d21cac391e6feced7aaChris Lattner // #include_next. 1100e305e81f65d13e6953f623a6b31176ad7041ba20Chad Rosier unsigned NonSystemRemoved = RemoveDuplicates(SearchList, NumQuoted, Verbose); 1101e305e81f65d13e6953f623a6b31176ad7041ba20Chad Rosier NumAngled -= NonSystemRemoved; 11020fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber 11030fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber bool DontSearchCurDir = false; // TODO: set to true if -I- is set? 1104ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner Headers.SetSearchPaths(SearchList, NumQuoted, NumAngled, DontSearchCurDir); 11050fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber 11060fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // If verbose, print the list of directories that will be searched. 11070fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber if (Verbose) { 1108e7cb7e4570842297f698bd7fd8d85520fc008acdDaniel Dunbar llvm::errs() << "#include \"...\" search starts here:\n"; 11090fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber for (unsigned i = 0, e = SearchList.size(); i != e; ++i) { 1110ebb6164bebf2b1e4f439433e751710b506918f62Chris Lattner if (i == NumQuoted) 1111e7cb7e4570842297f698bd7fd8d85520fc008acdDaniel Dunbar llvm::errs() << "#include <...> search starts here:\n"; 11120fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber const char *Name = SearchList[i].getName(); 11130fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber const char *Suffix; 11140fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber if (SearchList[i].isNormalDir()) 11150fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber Suffix = ""; 11160fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber else if (SearchList[i].isFramework()) 11170fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber Suffix = " (framework directory)"; 11180fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber else { 11190fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber assert(SearchList[i].isHeaderMap() && "Unknown DirectoryLookup"); 11200fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber Suffix = " (headermap)"; 11210fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 1122e7cb7e4570842297f698bd7fd8d85520fc008acdDaniel Dunbar llvm::errs() << " " << Name << Suffix << "\n"; 11230fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 1124e7cb7e4570842297f698bd7fd8d85520fc008acdDaniel Dunbar llvm::errs() << "End of search list.\n"; 11250fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 11260fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber} 112763c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar 11285814e657c9ad9ef6049a2a4af0d2aad248a8a15cDaniel Dunbarvoid clang::ApplyHeaderSearchOptions(HeaderSearch &HS, 11295814e657c9ad9ef6049a2a4af0d2aad248a8a15cDaniel Dunbar const HeaderSearchOptions &HSOpts, 11305814e657c9ad9ef6049a2a4af0d2aad248a8a15cDaniel Dunbar const LangOptions &Lang, 113163c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar const llvm::Triple &Triple) { 113263c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar InitHeaderSearch Init(HS, HSOpts.Verbose, HSOpts.Sysroot); 113363c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar 113463c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar // Add the user defined entries. 113563c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar for (unsigned i = 0, e = HSOpts.UserEntries.size(); i != e; ++i) { 113663c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar const HeaderSearchOptions::Entry &E = HSOpts.UserEntries[i]; 11371b483e70ad3f670f6dd0bc62dbe0921a28195f24Daniel Dunbar Init.AddPath(E.Path, E.Group, false, E.IsUserSupplied, E.IsFramework, 11385dd45f13dc4463f0c18b923fe6795ce55103301dBob Wilson E.IgnoreSysRoot); 113963c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar } 114063c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar 1141dd35ce9a783dea7e6660f9cb1d973742f3b3c73fDaniel Dunbar if (HSOpts.UseStandardIncludes) 114279bc57c074cb91f574fba19215f95b63dcf6b04bmike-m Init.AddDefaultSystemIncludePaths(Lang, Triple, HSOpts); 114363c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar 11442df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger Init.Realize(Lang); 114563c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar} 1146