InitHeaderSearch.cpp revision 199e09a93813516a5e8f9ce2c3cd4c18d60961db
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; 482cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar HeaderSearch& Headers; 492cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar bool Verbose; 50af6530c938bfc60902f0dfec1c0808aedbee1663Michael J. Spencer std::string IncludeSysroot; 51af6530c938bfc60902f0dfec1c0808aedbee1663Michael J. Spencer bool IsNotEmptyOrRoot; 522cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar 532cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbarpublic: 542cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar 55c09265a5fd94af5dcfd7325d0cb4f04197d65afcChandler Carruth InitHeaderSearch(HeaderSearch &HS, bool verbose, llvm::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. 61e89ba59005479529f5567f12b436617a2ca73ec2Benjamin Kramer void AddPath(const llvm::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++. 67e89ba59005479529f5567f12b436617a2ca73ec2Benjamin Kramer void AddGnuCPlusPlusIncludePaths(llvm::StringRef Base, 68e89ba59005479529f5567f12b436617a2ca73ec2Benjamin Kramer llvm::StringRef ArchDir, 69e89ba59005479529f5567f12b436617a2ca73ec2Benjamin Kramer llvm::StringRef Dir32, 70e89ba59005479529f5567f12b436617a2ca73ec2Benjamin Kramer llvm::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++. 75e89ba59005479529f5567f12b436617a2ca73ec2Benjamin Kramer void AddMinGWCPlusPlusIncludePaths(llvm::StringRef Base, 76e89ba59005479529f5567f12b436617a2ca73ec2Benjamin Kramer llvm::StringRef Arch, 77e89ba59005479529f5567f12b436617a2ca73ec2Benjamin Kramer llvm::StringRef Version); 782cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar 799db48467f19d4f0929a5ba40c5e2bd7255dc95f0NAKAMURA Takumi /// AddMinGW64CXXPaths - Add the necessary paths to support 809db48467f19d4f0929a5ba40c5e2bd7255dc95f0NAKAMURA Takumi /// libstdc++ of x86_64-w64-mingw32 aka mingw-w64. 819db48467f19d4f0929a5ba40c5e2bd7255dc95f0NAKAMURA Takumi void AddMinGW64CXXPaths(llvm::StringRef Base); 829db48467f19d4f0929a5ba40c5e2bd7255dc95f0NAKAMURA Takumi 832cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar /// AddDelimitedPaths - Add a list of paths delimited by the system PATH 842cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar /// separator. The processing follows that of the CPATH variable for gcc. 859e9ddf6100fd50ca2f9f9d0106b856e20b43300fBenjamin Kramer void AddDelimitedPaths(llvm::StringRef String); 862cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar 872cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar // AddDefaultCIncludePaths - Add paths that should always be searched. 8879bc57c074cb91f574fba19215f95b63dcf6b04bmike-m void AddDefaultCIncludePaths(const llvm::Triple &triple, 8979bc57c074cb91f574fba19215f95b63dcf6b04bmike-m const HeaderSearchOptions &HSOpts); 902cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar 912cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar // AddDefaultCPlusPlusIncludePaths - Add paths that should be searched when 922cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar // compiling c++. 932cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar void AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple); 942cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar 952cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar /// AddDefaultSystemIncludePaths - Adds the default system include paths so 962cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar /// that e.g. stdio.h is found. 972cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar void AddDefaultSystemIncludePaths(const LangOptions &Lang, 984c2bcad7b843c10fd4a2ffd43da40bfefb4dc8baDouglas Gregor const llvm::Triple &triple, 9979bc57c074cb91f574fba19215f95b63dcf6b04bmike-m const HeaderSearchOptions &HSOpts); 1002cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar 1012cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar /// Realize - Merges all search path lists into one list and send it to 1022cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar /// HeaderSearch. 1032df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger void Realize(const LangOptions &Lang); 1042cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar}; 1052cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar 1062cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar} 1070fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber 108e89ba59005479529f5567f12b436617a2ca73ec2Benjamin Kramervoid InitHeaderSearch::AddPath(const llvm::Twine &Path, 109458fb10ef5ba2d7b375c6c64095c1458af0a5be3Benjamin Kramer IncludeDirGroup Group, bool isCXXAware, 110458fb10ef5ba2d7b375c6c64095c1458af0a5be3Benjamin Kramer bool isUserSupplied, bool isFramework, 111458fb10ef5ba2d7b375c6c64095c1458af0a5be3Benjamin Kramer bool IgnoreSysRoot) { 112e89ba59005479529f5567f12b436617a2ca73ec2Benjamin Kramer assert(!Path.isTriviallyEmpty() && "can't handle empty path here"); 1130fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber FileManager &FM = Headers.getFileMgr(); 1141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1150fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // Compute the actual path, taking into consideration -isysroot. 1165853b0f117ee811388219bce738b24835b8d7fb2Chandler Carruth llvm::SmallString<256> MappedPathStorage; 117f3721457cd9f364f262e7a2d61edcdad05996e61Chandler Carruth llvm::StringRef MappedPathStr = Path.toStringRef(MappedPathStorage); 1181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1190fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // Handle isysroot. 1209a7e09d82f739c8fd1b6c28787397d698515a871Rafael Espindola if ((Group == System || Group == CXXSystem) && !IgnoreSysRoot && 1210f0cdab31a4f71914b7f654501d69d96e9f378daNAKAMURA Takumi#if defined(_WIN32) 1220f0cdab31a4f71914b7f654501d69d96e9f378daNAKAMURA Takumi !MappedPathStr.empty() && 1230f0cdab31a4f71914b7f654501d69d96e9f378daNAKAMURA Takumi llvm::sys::path::is_separator(MappedPathStr[0]) && 1240f0cdab31a4f71914b7f654501d69d96e9f378daNAKAMURA Takumi#else 125256053b31e697fdf0cc48f17d621c82fc3b8dff0Michael J. Spencer llvm::sys::path::is_absolute(MappedPathStr) && 1260f0cdab31a4f71914b7f654501d69d96e9f378daNAKAMURA Takumi#endif 127af6530c938bfc60902f0dfec1c0808aedbee1663Michael J. Spencer IsNotEmptyOrRoot) { 1285619ae5d25dc77410a444c86606d4ec9bae8b921Chandler Carruth MappedPathStorage.clear(); 129c09265a5fd94af5dcfd7325d0cb4f04197d65afcChandler Carruth MappedPathStr = 130af6530c938bfc60902f0dfec1c0808aedbee1663Michael J. Spencer (IncludeSysroot + Path).toStringRef(MappedPathStorage); 1310fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 1321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1330fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // Compute the DirectoryLookup type. 1349d72851fec9e9c62570a027d42701562bbf29751Chris Lattner SrcMgr::CharacteristicKind Type; 1350fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber if (Group == Quoted || Group == Angled) 1360b9e736308af5397f558ffc8e780c438c2fdb563Chris Lattner Type = SrcMgr::C_User; 1370fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber else if (isCXXAware) 1380b9e736308af5397f558ffc8e780c438c2fdb563Chris Lattner Type = SrcMgr::C_System; 1390fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber else 1400b9e736308af5397f558ffc8e780c438c2fdb563Chris Lattner Type = SrcMgr::C_ExternCSystem; 1411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1430fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // If the directory exists, add it. 14439b49bcaaddb1049234fca9500c0ac02c088e23dChris Lattner if (const DirectoryEntry *DE = FM.getDirectory(MappedPathStr)) { 1452df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger IncludePath.push_back(std::make_pair(Group, DirectoryLookup(DE, Type, 1462df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger isUserSupplied, isFramework))); 1470fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber return; 1480fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 1491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1500fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // Check to see if this is an apple-style headermap (which are not allowed to 1510fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // be frameworks). 1520fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber if (!isFramework) { 15339b49bcaaddb1049234fca9500c0ac02c088e23dChris Lattner if (const FileEntry *FE = FM.getFile(MappedPathStr)) { 1540fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber if (const HeaderMap *HM = Headers.CreateHeaderMap(FE)) { 1550fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // It is a headermap, add it to the search path. 1562df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger IncludePath.push_back(std::make_pair(Group, DirectoryLookup(HM, Type, 1572df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger isUserSupplied))); 1580fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber return; 1590fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 1600fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 1610fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 1621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1630fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber if (Verbose) 164f3721457cd9f364f262e7a2d61edcdad05996e61Chandler Carruth llvm::errs() << "ignoring nonexistent directory \"" 165f3721457cd9f364f262e7a2d61edcdad05996e61Chandler Carruth << MappedPathStr << "\"\n"; 1660fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber} 1670fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber 1680fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber 1699e9ddf6100fd50ca2f9f9d0106b856e20b43300fBenjamin Kramervoid InitHeaderSearch::AddDelimitedPaths(llvm::StringRef at) { 1709e9ddf6100fd50ca2f9f9d0106b856e20b43300fBenjamin Kramer if (at.empty()) // Empty string should not add '.' path. 1710fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber return; 1720fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber 1739e9ddf6100fd50ca2f9f9d0106b856e20b43300fBenjamin Kramer llvm::StringRef::size_type delim; 1749e9ddf6100fd50ca2f9f9d0106b856e20b43300fBenjamin Kramer while ((delim = at.find(llvm::sys::PathSeparator)) != llvm::StringRef::npos) { 1759e9ddf6100fd50ca2f9f9d0106b856e20b43300fBenjamin Kramer if (delim == 0) 1760fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber AddPath(".", Angled, false, true, false); 1770fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber else 1789e9ddf6100fd50ca2f9f9d0106b856e20b43300fBenjamin Kramer AddPath(at.substr(0, delim), Angled, false, true, false); 1799e9ddf6100fd50ca2f9f9d0106b856e20b43300fBenjamin Kramer at = at.substr(delim + 1); 1800fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 1819e9ddf6100fd50ca2f9f9d0106b856e20b43300fBenjamin Kramer 1829e9ddf6100fd50ca2f9f9d0106b856e20b43300fBenjamin Kramer if (at.empty()) 1830fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber AddPath(".", Angled, false, true, false); 1840fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber else 1850fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber AddPath(at, Angled, false, true, false); 1860fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber} 1870fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber 188e89ba59005479529f5567f12b436617a2ca73ec2Benjamin Kramervoid InitHeaderSearch::AddGnuCPlusPlusIncludePaths(llvm::StringRef Base, 189e89ba59005479529f5567f12b436617a2ca73ec2Benjamin Kramer llvm::StringRef ArchDir, 190e89ba59005479529f5567f12b436617a2ca73ec2Benjamin Kramer llvm::StringRef Dir32, 191e89ba59005479529f5567f12b436617a2ca73ec2Benjamin Kramer llvm::StringRef Dir64, 19231b63beefa058aa42a12a1c2b72b43a4ba21f7f1Rafael Espindola const llvm::Triple &triple) { 1936ec18a3f86c702004af66cce6ff979999a736898Rafael Espindola // Add the base dir 1942df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger AddPath(Base, CXXSystem, true, false, false); 195ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola 196ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola // Add the multilib dirs 19731b63beefa058aa42a12a1c2b72b43a4ba21f7f1Rafael Espindola llvm::Triple::ArchType arch = triple.getArch(); 19831b63beefa058aa42a12a1c2b72b43a4ba21f7f1Rafael Espindola bool is64bit = arch == llvm::Triple::ppc64 || arch == llvm::Triple::x86_64; 19931b63beefa058aa42a12a1c2b72b43a4ba21f7f1Rafael Espindola if (is64bit) 2002df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger AddPath(Base + "/" + ArchDir + "/" + Dir64, CXXSystem, true, false, false); 20131b63beefa058aa42a12a1c2b72b43a4ba21f7f1Rafael Espindola else 2022df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger AddPath(Base + "/" + ArchDir + "/" + Dir32, CXXSystem, true, false, false); 2036ec18a3f86c702004af66cce6ff979999a736898Rafael Espindola 2046ec18a3f86c702004af66cce6ff979999a736898Rafael Espindola // Add the backward dir 2052df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger AddPath(Base + "/backward", CXXSystem, true, false, false); 2062e9f652d53346bf7e64c8a12a9ff06b004a3e489Rafael Espindola} 2070fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber 208e89ba59005479529f5567f12b436617a2ca73ec2Benjamin Kramervoid InitHeaderSearch::AddMinGWCPlusPlusIncludePaths(llvm::StringRef Base, 209e89ba59005479529f5567f12b436617a2ca73ec2Benjamin Kramer llvm::StringRef Arch, 210e89ba59005479529f5567f12b436617a2ca73ec2Benjamin Kramer llvm::StringRef Version) { 211ab8ae19ea4285a15ca43123e8e218e401dc5cb5aBenjamin Kramer AddPath(Base + "/" + Arch + "/" + Version + "/include/c++", 2122df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger CXXSystem, true, false, false); 2138e9006bb31184a38b7c4c9d3d3040394652cbd9bChris Lattner AddPath(Base + "/" + Arch + "/" + Version + "/include/c++/" + Arch, 2142df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger CXXSystem, true, false, false); 215ab8ae19ea4285a15ca43123e8e218e401dc5cb5aBenjamin Kramer AddPath(Base + "/" + Arch + "/" + Version + "/include/c++/backward", 2162df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger CXXSystem, true, false, false); 217620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump} 21843d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump 2199db48467f19d4f0929a5ba40c5e2bd7255dc95f0NAKAMURA Takumivoid InitHeaderSearch::AddMinGW64CXXPaths(llvm::StringRef Base) { 2209db48467f19d4f0929a5ba40c5e2bd7255dc95f0NAKAMURA Takumi AddPath(Base, 2219db48467f19d4f0929a5ba40c5e2bd7255dc95f0NAKAMURA Takumi CXXSystem, true, false, false); 2229db48467f19d4f0929a5ba40c5e2bd7255dc95f0NAKAMURA Takumi AddPath(Base + "/x86_64-w64-mingw32", 2239db48467f19d4f0929a5ba40c5e2bd7255dc95f0NAKAMURA Takumi CXXSystem, true, false, false); 2249db48467f19d4f0929a5ba40c5e2bd7255dc95f0NAKAMURA Takumi AddPath(Base + "/backward", 2259db48467f19d4f0929a5ba40c5e2bd7255dc95f0NAKAMURA Takumi CXXSystem, true, false, false); 2269db48467f19d4f0929a5ba40c5e2bd7255dc95f0NAKAMURA Takumi} 2279db48467f19d4f0929a5ba40c5e2bd7255dc95f0NAKAMURA Takumi 228620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump // FIXME: This probably should goto to some platform utils place. 229620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump#ifdef _MSC_VER 23075ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson 231620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump // Read registry string. 23275ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // This also supports a means to look for high-versioned keys by use 23375ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // of a $VERSION placeholder in the key path. 23475ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // $VERSION in the key path is a placeholder for the version number, 23575ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // causing the highest value path to be searched for and used. 23675ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // I.e. "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\$VERSION". 23775ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // There can be additional characters in the component. Only the numberic 23875ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // characters are compared. 2396cd5216bb61e6165d8f6e8fb781d45c035bd4e00Benjamin Kramerstatic bool getSystemRegistryString(const char *keyPath, const char *valueName, 2406cd5216bb61e6165d8f6e8fb781d45c035bd4e00Benjamin Kramer char *value, size_t maxLength) { 24143d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump HKEY hRootKey = NULL; 24243d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump HKEY hKey = NULL; 24343d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump const char* subKey = NULL; 24443d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump DWORD valueType; 24543d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump DWORD valueSize = maxLength - 1; 24675ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson long lResult; 24743d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump bool returnValue = false; 24843d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump if (strncmp(keyPath, "HKEY_CLASSES_ROOT\\", 18) == 0) { 24943d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump hRootKey = HKEY_CLASSES_ROOT; 25043d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump subKey = keyPath + 18; 25143d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump } 25243d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump else if (strncmp(keyPath, "HKEY_USERS\\", 11) == 0) { 25343d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump hRootKey = HKEY_USERS; 25443d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump subKey = keyPath + 11; 25543d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump } 25643d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump else if (strncmp(keyPath, "HKEY_LOCAL_MACHINE\\", 19) == 0) { 25743d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump hRootKey = HKEY_LOCAL_MACHINE; 25843d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump subKey = keyPath + 19; 259121e3c207415fb4c105d690de384d8f3d49b0f2dArgyrios Kyrtzidis } 26043d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump else if (strncmp(keyPath, "HKEY_CURRENT_USER\\", 18) == 0) { 26143d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump hRootKey = HKEY_CURRENT_USER; 26243d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump subKey = keyPath + 18; 26343d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump } 26443d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump else 26543d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump return(false); 26675ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson const char *placeHolder = strstr(subKey, "$VERSION"); 26775ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson char bestName[256]; 26875ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson bestName[0] = '\0'; 26975ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // If we have a $VERSION placeholder, do the highest-version search. 27075ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson if (placeHolder) { 27175ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson const char *keyEnd = placeHolder - 1; 27275ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson const char *nextKey = placeHolder; 27375ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // Find end of previous key. 27475ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson while ((keyEnd > subKey) && (*keyEnd != '\\')) 27575ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson keyEnd--; 27675ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // Find end of key containing $VERSION. 27775ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson while (*nextKey && (*nextKey != '\\')) 27875ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson nextKey++; 27975ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson size_t partialKeyLength = keyEnd - subKey; 28075ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson char partialKey[256]; 28175ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson if (partialKeyLength > sizeof(partialKey)) 28275ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson partialKeyLength = sizeof(partialKey); 28375ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson strncpy(partialKey, subKey, partialKeyLength); 28475ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson partialKey[partialKeyLength] = '\0'; 28575ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson HKEY hTopKey = NULL; 28675ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson lResult = RegOpenKeyEx(hRootKey, partialKey, 0, KEY_READ, &hTopKey); 28775ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson if (lResult == ERROR_SUCCESS) { 28875ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson char keyName[256]; 28975ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson int bestIndex = -1; 29075ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson double bestValue = 0.0; 29175ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson DWORD index, size = sizeof(keyName) - 1; 29233cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes for (index = 0; RegEnumKeyEx(hTopKey, index, keyName, &size, NULL, 29333cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes NULL, NULL, NULL) == ERROR_SUCCESS; index++) { 29433cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes const char *sp = keyName; 29533cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes while (*sp && !isdigit(*sp)) 29633cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes sp++; 29733cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes if (!*sp) 29833cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes continue; 29933cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes const char *ep = sp + 1; 30033cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes while (*ep && (isdigit(*ep) || (*ep == '.'))) 30133cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes ep++; 30233cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes char numBuf[32]; 30333cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes strncpy(numBuf, sp, sizeof(numBuf) - 1); 30433cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes numBuf[sizeof(numBuf) - 1] = '\0'; 30533cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes double value = strtod(numBuf, NULL); 30633cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes if (value > bestValue) { 30733cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes bestIndex = (int)index; 30833cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes bestValue = value; 30933cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes strcpy(bestName, keyName); 31033cc2437ae3a609cdc44179931a2909eb48a8200Nuno Lopes } 31175ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson size = sizeof(keyName) - 1; 31275ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson } 31375ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // If we found the highest versioned key, open the key and get the value. 31475ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson if (bestIndex != -1) { 31575ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // Append rest of key. 31675ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson strncat(bestName, nextKey, sizeof(bestName) - 1); 31775ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson bestName[sizeof(bestName) - 1] = '\0'; 31875ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // Open the chosen key path remainder. 31975ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson lResult = RegOpenKeyEx(hTopKey, bestName, 0, KEY_READ, &hKey); 32075ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson if (lResult == ERROR_SUCCESS) { 32175ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson lResult = RegQueryValueEx(hKey, valueName, NULL, &valueType, 32275ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson (LPBYTE)value, &valueSize); 32375ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson if (lResult == ERROR_SUCCESS) 32475ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson returnValue = true; 32575ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson RegCloseKey(hKey); 32675ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson } 32775ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson } 32875ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson RegCloseKey(hTopKey); 32975ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson } 33075ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson } 33175ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson else { 33275ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson lResult = RegOpenKeyEx(hRootKey, subKey, 0, KEY_READ, &hKey); 33375ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson if (lResult == ERROR_SUCCESS) { 33475ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson lResult = RegQueryValueEx(hKey, valueName, NULL, &valueType, 33575ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson (LPBYTE)value, &valueSize); 33675ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson if (lResult == ERROR_SUCCESS) 33775ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson returnValue = true; 33875ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson RegCloseKey(hKey); 33975ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson } 34043d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump } 34143d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump return(returnValue); 34243d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump} 343620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump#else // _MSC_VER 344620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump // Read registry string. 3456cd5216bb61e6165d8f6e8fb781d45c035bd4e00Benjamin Kramerstatic bool getSystemRegistryString(const char*, const char*, char*, size_t) { 346620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump return(false); 347620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump} 348620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump#endif // _MSC_VER 349121e3c207415fb4c105d690de384d8f3d49b0f2dArgyrios Kyrtzidis 35043d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump // Get Visual Studio installation directory. 3516cd5216bb61e6165d8f6e8fb781d45c035bd4e00Benjamin Kramerstatic bool getVisualStudioDir(std::string &path) { 352ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer // First check the environment variables that vsvars32.bat sets. 353ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer const char* vcinstalldir = getenv("VCINSTALLDIR"); 354ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer if(vcinstalldir) { 355ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer char *p = const_cast<char *>(strstr(vcinstalldir, "\\VC")); 356ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer if (p) 357ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer *p = '\0'; 358ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer path = vcinstalldir; 359ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer return(true); 360ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer } 361ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer 36275ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson char vsIDEInstallDir[256]; 36380f93d9fe82ebe7e58913646248240de838283beDouglas Gregor char vsExpressIDEInstallDir[256]; 364ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer // Then try the windows registry. 36575ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson bool hasVCDir = getSystemRegistryString( 36675ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\$VERSION", 36775ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson "InstallDir", vsIDEInstallDir, sizeof(vsIDEInstallDir) - 1); 36880f93d9fe82ebe7e58913646248240de838283beDouglas Gregor bool hasVCExpressDir = getSystemRegistryString( 36980f93d9fe82ebe7e58913646248240de838283beDouglas Gregor "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\$VERSION", 37080f93d9fe82ebe7e58913646248240de838283beDouglas Gregor "InstallDir", vsExpressIDEInstallDir, sizeof(vsExpressIDEInstallDir) - 1); 371125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi // If we have both vc80 and vc90, pick version we were compiled with. 37275ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson if (hasVCDir && vsIDEInstallDir[0]) { 373620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump char *p = (char*)strstr(vsIDEInstallDir, "\\Common7\\IDE"); 374620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump if (p) 375620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump *p = '\0'; 376620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump path = vsIDEInstallDir; 377620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump return(true); 37843d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump } 37980f93d9fe82ebe7e58913646248240de838283beDouglas Gregor else if (hasVCExpressDir && vsExpressIDEInstallDir[0]) { 38080f93d9fe82ebe7e58913646248240de838283beDouglas Gregor char *p = (char*)strstr(vsExpressIDEInstallDir, "\\Common7\\IDE"); 38180f93d9fe82ebe7e58913646248240de838283beDouglas Gregor if (p) 38280f93d9fe82ebe7e58913646248240de838283beDouglas Gregor *p = '\0'; 38380f93d9fe82ebe7e58913646248240de838283beDouglas Gregor path = vsExpressIDEInstallDir; 38480f93d9fe82ebe7e58913646248240de838283beDouglas Gregor return(true); 38580f93d9fe82ebe7e58913646248240de838283beDouglas Gregor } 386620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump else { 387620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump // Try the environment. 38880f93d9fe82ebe7e58913646248240de838283beDouglas Gregor const char* vs100comntools = getenv("VS100COMNTOOLS"); 389620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump const char* vs90comntools = getenv("VS90COMNTOOLS"); 390620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump const char* vs80comntools = getenv("VS80COMNTOOLS"); 391620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump const char* vscomntools = NULL; 39280f93d9fe82ebe7e58913646248240de838283beDouglas Gregor 393125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi // Try to find the version that we were compiled with 39480f93d9fe82ebe7e58913646248240de838283beDouglas Gregor if(false) {} 39580f93d9fe82ebe7e58913646248240de838283beDouglas Gregor #if (_MSC_VER >= 1600) // VC100 39680f93d9fe82ebe7e58913646248240de838283beDouglas Gregor else if(vs100comntools) { 39780f93d9fe82ebe7e58913646248240de838283beDouglas Gregor vscomntools = vs100comntools; 398620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump } 39980f93d9fe82ebe7e58913646248240de838283beDouglas Gregor #elif (_MSC_VER == 1500) // VC80 40080f93d9fe82ebe7e58913646248240de838283beDouglas Gregor else if(vs90comntools) { 40180f93d9fe82ebe7e58913646248240de838283beDouglas Gregor vscomntools = vs90comntools; 40280f93d9fe82ebe7e58913646248240de838283beDouglas Gregor } 40380f93d9fe82ebe7e58913646248240de838283beDouglas Gregor #elif (_MSC_VER == 1400) // VC80 40480f93d9fe82ebe7e58913646248240de838283beDouglas Gregor else if(vs80comntools) { 40580f93d9fe82ebe7e58913646248240de838283beDouglas Gregor vscomntools = vs80comntools; 40680f93d9fe82ebe7e58913646248240de838283beDouglas Gregor } 40780f93d9fe82ebe7e58913646248240de838283beDouglas Gregor #endif 40880f93d9fe82ebe7e58913646248240de838283beDouglas Gregor // Otherwise find any version we can 40980f93d9fe82ebe7e58913646248240de838283beDouglas Gregor else if (vs100comntools) 41080f93d9fe82ebe7e58913646248240de838283beDouglas Gregor vscomntools = vs100comntools; 411620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump else if (vs90comntools) 412620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump vscomntools = vs90comntools; 413620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump else if (vs80comntools) 414620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump vscomntools = vs80comntools; 41580f93d9fe82ebe7e58913646248240de838283beDouglas Gregor 416620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump if (vscomntools && *vscomntools) { 417cb421fa690da545b58a720abe5f1c49b166dbde7Dan Gohman char *p = const_cast<char *>(strstr(vscomntools, "\\Common7\\Tools")); 418620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump if (p) 419620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump *p = '\0'; 420620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump path = vscomntools; 421620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump return(true); 422620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump } 423620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump else 424620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump return(false); 425620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump } 426620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump return(false); 42743d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump} 4284d374d4a4832a01d5d3b75c59cb1567e60df41e7Sebastian Redl 42975ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // Get Windows SDK installation directory. 4306cd5216bb61e6165d8f6e8fb781d45c035bd4e00Benjamin Kramerstatic bool getWindowsSDKDir(std::string &path) { 43175ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson char windowsSDKInstallDir[256]; 43275ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson // Try the Windows registry. 43375ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson bool hasSDKDir = getSystemRegistryString( 43475ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\$VERSION", 43575ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson "InstallationFolder", windowsSDKInstallDir, sizeof(windowsSDKInstallDir) - 1); 436125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi // If we have both vc80 and vc90, pick version we were compiled with. 43775ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson if (hasSDKDir && windowsSDKInstallDir[0]) { 43875ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson path = windowsSDKInstallDir; 43975ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson return(true); 44075ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson } 44175ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson return(false); 44275ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson} 44375ee3bd6e7ed2b4286d5e717ae7b94411f90b3b9John Thompson 44479bc57c074cb91f574fba19215f95b63dcf6b04bmike-mvoid InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple, 44579bc57c074cb91f574fba19215f95b63dcf6b04bmike-m const HeaderSearchOptions &HSOpts) { 4468e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer llvm::Triple::OSType os = triple.getOS(); 4478e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer 4488e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer switch (os) { 449630766057eabe78f9bb2e0c0d023223fb8d0174eRoman Divacky case llvm::Triple::FreeBSD: 4508e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer case llvm::Triple::NetBSD: 4518e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer break; 4528e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer default: 4538e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer // FIXME: temporary hack: hard-coded paths. 4548e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer AddPath("/usr/local/include", System, true, false, false); 4558e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer break; 4568e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer } 45779bc57c074cb91f574fba19215f95b63dcf6b04bmike-m 45879bc57c074cb91f574fba19215f95b63dcf6b04bmike-m // Builtin includes use #include_next directives and should be positioned 45979bc57c074cb91f574fba19215f95b63dcf6b04bmike-m // just prior C include dirs. 46079bc57c074cb91f574fba19215f95b63dcf6b04bmike-m if (HSOpts.UseBuiltinIncludes) { 46179bc57c074cb91f574fba19215f95b63dcf6b04bmike-m // Ignore the sys root, we *always* look for clang headers relative to 46279bc57c074cb91f574fba19215f95b63dcf6b04bmike-m // supplied path. 46379bc57c074cb91f574fba19215f95b63dcf6b04bmike-m llvm::sys::Path P(HSOpts.ResourceDir); 46479bc57c074cb91f574fba19215f95b63dcf6b04bmike-m P.appendComponent("include"); 46579bc57c074cb91f574fba19215f95b63dcf6b04bmike-m AddPath(P.str(), System, false, false, false, /*IgnoreSysRoot=*/ true); 46679bc57c074cb91f574fba19215f95b63dcf6b04bmike-m } 46779bc57c074cb91f574fba19215f95b63dcf6b04bmike-m 46879bc57c074cb91f574fba19215f95b63dcf6b04bmike-m // Add dirs specified via 'configure --with-c-include-dirs'. 469c706468b1e00bab49ca92eb500a39657f530f828Daniel Dunbar llvm::StringRef CIncludeDirs(C_INCLUDE_DIRS); 470c706468b1e00bab49ca92eb500a39657f530f828Daniel Dunbar if (CIncludeDirs != "") { 471aadd7a48453b4f58bd8e1e9eb670918ee7d6a711Rafael Espindola llvm::SmallVector<llvm::StringRef, 5> dirs; 472aadd7a48453b4f58bd8e1e9eb670918ee7d6a711Rafael Espindola CIncludeDirs.split(dirs, ":"); 473aadd7a48453b4f58bd8e1e9eb670918ee7d6a711Rafael Espindola for (llvm::SmallVectorImpl<llvm::StringRef>::iterator i = dirs.begin(); 474aadd7a48453b4f58bd8e1e9eb670918ee7d6a711Rafael Espindola i != dirs.end(); 475125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi ++i) 476f0a2f51be576089e1a84cd677c09156dae067b6aRafael Espindola AddPath(*i, System, false, false, false); 477f0a2f51be576089e1a84cd677c09156dae067b6aRafael Espindola return; 478f0a2f51be576089e1a84cd677c09156dae067b6aRafael Espindola } 4798e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer 48043d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump switch (os) { 481d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar case llvm::Triple::Win32: { 482d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar std::string VSDir; 483d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar std::string WindowsSDKDir; 484d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar if (getVisualStudioDir(VSDir)) { 485d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar AddPath(VSDir + "\\VC\\include", System, false, false, false); 486d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar if (getWindowsSDKDir(WindowsSDKDir)) 487d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar AddPath(WindowsSDKDir + "\\include", System, false, false, false); 488d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar else 489d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar AddPath(VSDir + "\\VC\\PlatformSDK\\Include", 490d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar System, false, false, false); 491d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar } else { 492d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar // Default install paths. 493d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar AddPath("C:/Program Files/Microsoft Visual Studio 10.0/VC/include", 494d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar System, false, false, false); 495d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar AddPath("C:/Program Files/Microsoft Visual Studio 9.0/VC/include", 496d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar System, false, false, false); 497d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar AddPath( 4989319f02dea2449caf5c7a0d07c596ca324e43574John Thompson "C:/Program Files/Microsoft Visual Studio 9.0/VC/PlatformSDK/Include", 499d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar System, false, false, false); 500d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar AddPath("C:/Program Files/Microsoft Visual Studio 8/VC/include", 501d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar System, false, false, false); 502d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar AddPath( 5039319f02dea2449caf5c7a0d07c596ca324e43574John Thompson "C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/Include", 504d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar System, false, false, false); 50543d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump } 50643d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump break; 507d11ee7f66213bc418df192b7724d3aed349a642cDaniel Dunbar } 50886ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner case llvm::Triple::Haiku: 50986ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/common/include", System, true, false, false); 51086ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os", System, true, false, false); 51186ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/app", System, true, false, false); 51286ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/arch", System, true, false, false); 51386ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/device", System, true, false, false); 51486ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/drivers", System, true, false, false); 515125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi AddPath("/boot/develop/headers/os/game", System, true, false, false); 51686ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/interface", System, true, false, false); 51786ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/kernel", System, true, false, false); 51886ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/locale", System, true, false, false); 51986ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/mail", System, true, false, false); 52086ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/media", System, true, false, false); 52186ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/midi", System, true, false, false); 52286ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/midi2", System, true, false, false); 52386ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/net", System, true, false, false); 52486ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/storage", System, true, false, false); 52586ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/support", System, true, false, false); 52686ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/translation", 52786ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner System, true, false, false); 528125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi AddPath("/boot/develop/headers/os/add-ons/graphics", 52986ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner System, true, false, false); 530125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi AddPath("/boot/develop/headers/os/add-ons/input_server", 53186ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner System, true, false, false); 532125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi AddPath("/boot/develop/headers/os/add-ons/screen_saver", 53386ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner System, true, false, false); 534125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi AddPath("/boot/develop/headers/os/add-ons/tracker", 53586ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner System, true, false, false); 53686ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/be_apps/Deskbar", 53786ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner System, true, false, false); 53886ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/be_apps/NetPositive", 53986ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner System, true, false, false); 54086ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/os/be_apps/Tracker", 54186ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner System, true, false, false); 54286ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/cpp", System, true, false, false); 543125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi AddPath("/boot/develop/headers/cpp/i586-pc-haiku", 54486ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner System, true, false, false); 54586ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/3rdparty", System, true, false, false); 54686ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/bsd", System, true, false, false); 54786ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/glibc", System, true, false, false); 54886ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers/posix", System, true, false, false); 54986ed3a326342fa2a8c9d9b5d1d7280c9bad2b007Chris Lattner AddPath("/boot/develop/headers", System, true, false, false); 550a7e6845660f91ec611427e1db842780e1ec12bdbEli Friedman break; 55132df002017e3e8d86bfd3f7090b341d265676fc9NAKAMURA Takumi case llvm::Triple::Cygwin: 55232df002017e3e8d86bfd3f7090b341d265676fc9NAKAMURA Takumi AddPath("/usr/include/w32api", System, true, false, false); 55332df002017e3e8d86bfd3f7090b341d265676fc9NAKAMURA Takumi break; 554620d57a293143e3f07d6e4f5ba50020a80f45564Mike Stump case llvm::Triple::MinGW32: 5559db48467f19d4f0929a5ba40c5e2bd7255dc95f0NAKAMURA Takumi // FIXME: We should be aware of i686-w64-mingw32. 5569db48467f19d4f0929a5ba40c5e2bd7255dc95f0NAKAMURA Takumi if (triple.getArch() == llvm::Triple::x86_64) 5579db48467f19d4f0929a5ba40c5e2bd7255dc95f0NAKAMURA Takumi AddPath("c:/mingw/x86_64-w64-mingw32/include", 5589db48467f19d4f0929a5ba40c5e2bd7255dc95f0NAKAMURA Takumi System, true, false, false); 559ab0d8bde2d8ab54aae3a0d9fce11f29b3d1d0bb4Douglas Gregor AddPath("/mingw/include", System, true, false, false); 56043d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump AddPath("c:/mingw/include", System, true, false, false); 56143d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump break; 56243d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump default: 56343d8176d2e8e304b2d419fb0fe139cc07af80deaMike Stump break; 5640fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 565d3f88343af2dec3459493fafa22532317321eaf0John Thompson 566d3f88343af2dec3459493fafa22532317321eaf0John Thompson AddPath("/usr/include", System, false, false, false); 567e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola} 568e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola 5690e3cc05542e62fe89345ce94a73494525ee463e0Chris Lattnervoid InitHeaderSearch:: 5700e3cc05542e62fe89345ce94a73494525ee463e0Chris LattnerAddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple) { 571e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola llvm::Triple::OSType os = triple.getOS(); 572ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola llvm::StringRef CxxIncludeRoot(CXX_INCLUDE_ROOT); 573ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola if (CxxIncludeRoot != "") { 574ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola llvm::StringRef CxxIncludeArch(CXX_INCLUDE_ARCH); 575ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola if (CxxIncludeArch == "") 576ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola AddGnuCPlusPlusIncludePaths(CxxIncludeRoot, triple.str().c_str(), 5770e3cc05542e62fe89345ce94a73494525ee463e0Chris Lattner CXX_INCLUDE_32BIT_DIR, CXX_INCLUDE_64BIT_DIR, 5780e3cc05542e62fe89345ce94a73494525ee463e0Chris Lattner triple); 579ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola else 580ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola AddGnuCPlusPlusIncludePaths(CxxIncludeRoot, CXX_INCLUDE_ARCH, 5810e3cc05542e62fe89345ce94a73494525ee463e0Chris Lattner CXX_INCLUDE_32BIT_DIR, CXX_INCLUDE_64BIT_DIR, 5820e3cc05542e62fe89345ce94a73494525ee463e0Chris Lattner triple); 583ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola return; 584ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola } 585e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola // FIXME: temporary hack: hard-coded paths. 586db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar 587db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar if (triple.isOSDarwin()) { 588f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar switch (triple.getArch()) { 589f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar default: break; 590f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar 591125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi case llvm::Triple::ppc: 592582c30135dce1857db62e58b916ab0fa5edfb1d6Douglas Gregor case llvm::Triple::ppc64: 593616d4362f01a8f819f9351372c3c4368777d4480Douglas Gregor AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1", 594125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi "powerpc-apple-darwin10", "", "ppc64", 595616d4362f01a8f819f9351372c3c4368777d4480Douglas Gregor triple); 596582c30135dce1857db62e58b916ab0fa5edfb1d6Douglas Gregor AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.0.0", 597125b4cb35536e45201f8f2cb19ee620e3ad67c49NAKAMURA Takumi "powerpc-apple-darwin10", "", "ppc64", 598582c30135dce1857db62e58b916ab0fa5edfb1d6Douglas Gregor triple); 599582c30135dce1857db62e58b916ab0fa5edfb1d6Douglas Gregor break; 600582c30135dce1857db62e58b916ab0fa5edfb1d6Douglas Gregor 601f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar case llvm::Triple::x86: 602f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar case llvm::Triple::x86_64: 603f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1", 604f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar "i686-apple-darwin10", "", "x86_64", triple); 605f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.0.0", 606f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar "i686-apple-darwin8", "", "", triple); 607f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar break; 608f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar 609f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar case llvm::Triple::arm: 610f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar case llvm::Triple::thumb: 611f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1", 612f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar "arm-apple-darwin10", "v7", "", triple); 613f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1", 614f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar "arm-apple-darwin10", "v6", "", triple); 615f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar break; 616f2070b374c1d6fc72aa6bdb2f49c1efdc4f6d963Daniel Dunbar } 617db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar return; 618db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar } 619db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar 620db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar switch (os) { 621db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar case llvm::Triple::Cygwin: 622db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar // Cygwin-1.7 623db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "4.3.4"); 624db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar // g++-4 / Cygwin-1.5 625db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "4.3.2"); 626db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar // FIXME: Do we support g++-3.4.4? 627db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "3.4.4"); 628db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar break; 629db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar case llvm::Triple::MinGW32: 630db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar // FIXME: We should be aware of i686-w64-mingw32. 631db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar if (triple.getArch() == llvm::Triple::x86_64) { 632db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar // mingw-w64-20110207 633db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar AddMinGW64CXXPaths("c:/mingw/x86_64-w64-mingw32/include/c++/4.5.3"); 634db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar // mingw-w64-20101129 635db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar AddMinGW64CXXPaths("c:/mingw/x86_64-w64-mingw32/include/c++/4.5.2"); 636db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar } 637db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar // Try gcc 4.5.2 (MSYS) 638db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar AddMinGWCPlusPlusIncludePaths("/mingw/lib/gcc", "mingw32", "4.5.2"); 639db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar // Try gcc 4.5.0 640db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", "mingw32", "4.5.0"); 641db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar // Try gcc 4.4.0 642db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", "mingw32", "4.4.0"); 643db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar // Try gcc 4.3.0 644db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", "mingw32", "4.3.0"); 645e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola break; 6467a7ca281bcf50b34de1ce067d3c55879b81722aeChris Lattner case llvm::Triple::DragonFly: 6472df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger AddPath("/usr/include/c++/4.1", CXXSystem, true, false, false); 6487a7ca281bcf50b34de1ce067d3c55879b81722aeChris Lattner break; 649e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola case llvm::Triple::Linux: 650ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m //===------------------------------------------------------------------===// 651ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Debian based distros. 652ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Note: these distros symlink /usr/include/c++/X.Y.Z -> X.Y 653ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m //===------------------------------------------------------------------===// 65414a011688d52794cf58fec8197e4518a54f03d80Axel Naumann // Ubuntu 11.04 "Natty Narwhal" -- gcc-4.5.2 65514a011688d52794cf58fec8197e4518a54f03d80Axel Naumann AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5", 65614a011688d52794cf58fec8197e4518a54f03d80Axel Naumann "x86_64-linux-gnu", "32", "", triple); 65714a011688d52794cf58fec8197e4518a54f03d80Axel Naumann AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5", 65814a011688d52794cf58fec8197e4518a54f03d80Axel Naumann "i686-linux-gnu", "", "64", triple); 65914a011688d52794cf58fec8197e4518a54f03d80Axel Naumann AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5", 66014a011688d52794cf58fec8197e4518a54f03d80Axel Naumann "i486-linux-gnu", "", "64", triple); 66114a011688d52794cf58fec8197e4518a54f03d80Axel Naumann AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5", 66214a011688d52794cf58fec8197e4518a54f03d80Axel Naumann "arm-linux-gnueabi", "", "", triple); 66314a011688d52794cf58fec8197e4518a54f03d80Axel Naumann 664c12bbe5cbee8936204d286e17d8e0511dd67ddb4Rafael Espindola // Ubuntu 10.10 "Maverick Meerkat" -- gcc-4.4.5 665adafdbae908a8e798fa4940ed89f61597b3d7ca5Rafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4", 666adafdbae908a8e798fa4940ed89f61597b3d7ca5Rafael Espindola "i686-linux-gnu", "", "64", triple); 667adafdbae908a8e798fa4940ed89f61597b3d7ca5Rafael Espindola // The rest of 10.10 is the same as previous versions. 668adafdbae908a8e798fa4940ed89f61597b3d7ca5Rafael Espindola 669ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Ubuntu 10.04 LTS "Lucid Lynx" -- gcc-4.4.3 670ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Ubuntu 9.10 "Karmic Koala" -- gcc-4.4.1 671ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Debian 6.0 "squeeze" -- gcc-4.4.2 672e69f047a6c882ce36bd260a8fed0ae31114a5a7eNick Lewycky AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4", 673331e8010aed1c2175328ed470aea75e93ff70b32Torok Edwin "x86_64-linux-gnu", "32", "", triple); 674e69f047a6c882ce36bd260a8fed0ae31114a5a7eNick Lewycky AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4", 675ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i486-linux-gnu", "", "64", triple); 676db0835552ff4b640bc908a50ccd075ab63cf6fffNick Lewycky AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4", 677db0835552ff4b640bc908a50ccd075ab63cf6fffNick Lewycky "arm-linux-gnueabi", "", "", triple); 678ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Ubuntu 9.04 "Jaunty Jackalope" -- gcc-4.3.3 679ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Ubuntu 8.10 "Intrepid Ibex" -- gcc-4.3.2 680ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Debian 5.0 "lenny" -- gcc-4.3.2 681ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3", 682ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "x86_64-linux-gnu", "32", "", triple); 683ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3", 684ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i486-linux-gnu", "", "64", triple); 685e7d6c2cae6a9b9985db02cfc8bb4e7b714630ed5Rafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3", 686e7d6c2cae6a9b9985db02cfc8bb4e7b714630ed5Rafael Espindola "arm-linux-gnueabi", "", "", triple); 687ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Ubuntu 8.04.4 LTS "Hardy Heron" -- gcc-4.2.4 688ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Ubuntu 8.04.[0-3] LTS "Hardy Heron" -- gcc-4.2.3 689ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2", 690ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "x86_64-linux-gnu", "32", "", triple); 691ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2", 692ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i486-linux-gnu", "", "64", triple); 693ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Ubuntu 7.10 "Gutsy Gibbon" -- gcc-4.1.3 694ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1", 695ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "x86_64-linux-gnu", "32", "", triple); 696ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1", 697ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i486-linux-gnu", "", "64", triple); 698189a14869a36ecf8bd5edc94255a34061044efe2Nuno Lopes 699ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m //===------------------------------------------------------------------===// 700ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Redhat based distros. 701ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m //===------------------------------------------------------------------===// 7028f1cc075c36212797ef52dac0e2fe35417a6bb6bEric Christopher // Fedora 15 7038f1cc075c36212797ef52dac0e2fe35417a6bb6bEric Christopher AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.0", 7048f1cc075c36212797ef52dac0e2fe35417a6bb6bEric Christopher "x86_64-redhat-linux", "32", "", triple); 7058f1cc075c36212797ef52dac0e2fe35417a6bb6bEric Christopher AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.0", 7068f1cc075c36212797ef52dac0e2fe35417a6bb6bEric Christopher "i686-redhat-linux", "", "", triple); 7076638b3a15edea25c4b1fdf8046e71d82683d8efaRafael Espindola // Fedora 14 7086638b3a15edea25c4b1fdf8046e71d82683d8efaRafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5.1", 7096638b3a15edea25c4b1fdf8046e71d82683d8efaRafael Espindola "x86_64-redhat-linux", "32", "", triple); 7106638b3a15edea25c4b1fdf8046e71d82683d8efaRafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5.1", 7116638b3a15edea25c4b1fdf8046e71d82683d8efaRafael Espindola "i686-redhat-linux", "", "", triple); 712ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Fedora 13 7134336e191cc52aa1ef72f9a542f5a6d5f9f02a825Chris Lattner AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.4", 7144336e191cc52aa1ef72f9a542f5a6d5f9f02a825Chris Lattner "x86_64-redhat-linux", "32", "", triple); 7154336e191cc52aa1ef72f9a542f5a6d5f9f02a825Chris Lattner AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.4", 7164336e191cc52aa1ef72f9a542f5a6d5f9f02a825Chris Lattner "i686-redhat-linux","", "", triple); 717ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Fedora 12 718ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.3", 7190720b5159010479c08f8264a8a209037ecf55922Chris Lattner "x86_64-redhat-linux", "32", "", triple); 720ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.3", 721ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i686-redhat-linux","", "", triple); 722ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Fedora 12 (pre-FEB-2010) 723ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.2", 724ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "x86_64-redhat-linux", "32", "", triple); 725ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.2", 726ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i686-redhat-linux","", "", triple); 727189a14869a36ecf8bd5edc94255a34061044efe2Nuno Lopes // Fedora 11 728189a14869a36ecf8bd5edc94255a34061044efe2Nuno Lopes AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.1", 729ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "x86_64-redhat-linux", "32", "", triple); 730ea00f847a0e1771b1fcfe683d3506940dc2de1ecChris Lattner AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.1", 731ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i586-redhat-linux","", "", triple); 732ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Fedora 10 733ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.2", 734ea00f847a0e1771b1fcfe683d3506940dc2de1ecChris Lattner "x86_64-redhat-linux", "32", "", triple); 735ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.2", 736ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i386-redhat-linux","", "", triple); 737ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Fedora 9 738ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.0", 739ea00f847a0e1771b1fcfe683d3506940dc2de1ecChris Lattner "x86_64-redhat-linux", "32", "", triple); 740ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.0", 741ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i386-redhat-linux", "", "", triple); 742ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Fedora 8 743ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1.2", 744ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "x86_64-redhat-linux", "", "", triple); 745ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1.2", 746ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i386-redhat-linux", "", "", triple); 747199e09a93813516a5e8f9ce2c3cd4c18d60961dbEric Christopher 748199e09a93813516a5e8f9ce2c3cd4c18d60961dbEric Christopher // RHEL 5 749199e09a93813516a5e8f9ce2c3cd4c18d60961dbEric Christopher AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1.1", 750199e09a93813516a5e8f9ce2c3cd4c18d60961dbEric Christopher "x86_64-redhat-linux", "32", "", triple); 751199e09a93813516a5e8f9ce2c3cd4c18d60961dbEric Christopher AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1.1", 752199e09a93813516a5e8f9ce2c3cd4c18d60961dbEric Christopher "i386-redhat-linux", "", "", triple); 753199e09a93813516a5e8f9ce2c3cd4c18d60961dbEric Christopher 754ea00f847a0e1771b1fcfe683d3506940dc2de1ecChris Lattner 755ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m //===------------------------------------------------------------------===// 756ea00f847a0e1771b1fcfe683d3506940dc2de1ecChris Lattner 757ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // Exherbo (2010-01-25) 758ea00f847a0e1771b1fcfe683d3506940dc2de1ecChris Lattner AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.3", 759ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "x86_64-pc-linux-gnu", "32", "", triple); 760ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.3", 761ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m "i686-pc-linux-gnu", "", "", triple); 762ea00f847a0e1771b1fcfe683d3506940dc2de1ecChris Lattner 763e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola // openSUSE 11.1 32 bit 764e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3", 765ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "i586-suse-linux", "", "", triple); 766e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola // openSUSE 11.1 64 bit 767e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3", 768ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "x86_64-suse-linux", "32", "", triple); 769e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola // openSUSE 11.2 770e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4", 771ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "i586-suse-linux", "", "", triple); 772e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4", 773ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "x86_64-suse-linux", "", "", triple); 7749d2c06001b0c09fdb0f973cd6f8fa5555aea1b5fRafael Espindola 7759d2c06001b0c09fdb0f973cd6f8fa5555aea1b5fRafael Espindola // openSUSE 11.4 7769d2c06001b0c09fdb0f973cd6f8fa5555aea1b5fRafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5", 7779d2c06001b0c09fdb0f973cd6f8fa5555aea1b5fRafael Espindola "i586-suse-linux", "", "", triple); 7789d2c06001b0c09fdb0f973cd6f8fa5555aea1b5fRafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5", 7799d2c06001b0c09fdb0f973cd6f8fa5555aea1b5fRafael Espindola "x86_64-suse-linux", "", "", triple); 7809d2c06001b0c09fdb0f973cd6f8fa5555aea1b5fRafael Espindola 781e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola // Arch Linux 2008-06-24 782e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.1", 783ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "i686-pc-linux-gnu", "", "", triple); 784e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.1", 785ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "x86_64-unknown-linux-gnu", "", "", triple); 786014f9720bc53cc748aa13b0773cd67428a9e6ae4Nico Weber 787014f9720bc53cc748aa13b0773cd67428a9e6ae4Nico Weber // Arch Linux gcc 4.6 788014f9720bc53cc748aa13b0773cd67428a9e6ae4Nico Weber AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.0", 789014f9720bc53cc748aa13b0773cd67428a9e6ae4Nico Weber "i686-pc-linux-gnu", "", "", triple); 790014f9720bc53cc748aa13b0773cd67428a9e6ae4Nico Weber AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.0", 791014f9720bc53cc748aa13b0773cd67428a9e6ae4Nico Weber "x86_64-unknown-linux-gnu", "", "", triple); 792014f9720bc53cc748aa13b0773cd67428a9e6ae4Nico Weber 7935370383567e32c840b728bd5d066db281710f2c1Douglas Gregor // Gentoo x86 gcc 4.5.2 7945370383567e32c840b728bd5d066db281710f2c1Douglas Gregor AddGnuCPlusPlusIncludePaths( 7955370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/g++-v4", 7965370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "i686-pc-linux-gnu", "", "", triple); 7975370383567e32c840b728bd5d066db281710f2c1Douglas Gregor // Gentoo x86 gcc 4.4.5 7985370383567e32c840b728bd5d066db281710f2c1Douglas Gregor AddGnuCPlusPlusIncludePaths( 7995370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "/usr/lib/gcc/i686-pc-linux-gnu/4.4.5/include/g++-v4", 8005370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "i686-pc-linux-gnu", "", "", triple); 8015370383567e32c840b728bd5d066db281710f2c1Douglas Gregor // Gentoo x86 gcc 4.4.4 8025370383567e32c840b728bd5d066db281710f2c1Douglas Gregor AddGnuCPlusPlusIncludePaths( 8035370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "/usr/lib/gcc/i686-pc-linux-gnu/4.4.4/include/g++-v4", 8045370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "i686-pc-linux-gnu", "", "", triple); 8055370383567e32c840b728bd5d066db281710f2c1Douglas Gregor // Gentoo x86 2010.0 stable 8060d155a5e1d6406d27df5779d0c9fb98d49a713a0Nuno Lopes AddGnuCPlusPlusIncludePaths( 8070d155a5e1d6406d27df5779d0c9fb98d49a713a0Nuno Lopes "/usr/lib/gcc/i686-pc-linux-gnu/4.4.3/include/g++-v4", 8080d155a5e1d6406d27df5779d0c9fb98d49a713a0Nuno Lopes "i686-pc-linux-gnu", "", "", triple); 809e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola // Gentoo x86 2009.1 stable 810e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths( 81140d1bb6383c14d5f8249d0640e8088a91b694c66John Thompson "/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4", 812ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "i686-pc-linux-gnu", "", "", triple); 813e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola // Gentoo x86 2009.0 stable 814e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths( 81540d1bb6383c14d5f8249d0640e8088a91b694c66John Thompson "/usr/lib/gcc/i686-pc-linux-gnu/4.3.2/include/g++-v4", 816ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "i686-pc-linux-gnu", "", "", triple); 817e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola // Gentoo x86 2008.0 stable 818e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths( 81940d1bb6383c14d5f8249d0640e8088a91b694c66John Thompson "/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4", 820ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "i686-pc-linux-gnu", "", "", triple); 8215370383567e32c840b728bd5d066db281710f2c1Douglas Gregor // Gentoo x86 llvm-gcc trunk 8225370383567e32c840b728bd5d066db281710f2c1Douglas Gregor AddGnuCPlusPlusIncludePaths( 8235370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "/usr/lib/llvm-gcc-4.2-9999/include/c++/4.2.1", 8245370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "i686-pc-linux-gnu", "", "", triple); 825fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth 8265370383567e32c840b728bd5d066db281710f2c1Douglas Gregor // Gentoo amd64 gcc 4.5.2 8275370383567e32c840b728bd5d066db281710f2c1Douglas Gregor AddGnuCPlusPlusIncludePaths( 8285370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/include/g++-v4", 8295370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "x86_64-pc-linux-gnu", "32", "", triple); 830fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth // Gentoo amd64 gcc 4.4.5 831e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths( 832fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth "/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.5/include/g++-v4", 833fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth "x86_64-pc-linux-gnu", "32", "", triple); 834fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth // Gentoo amd64 gcc 4.4.4 83570d9d4196e6531926ca18b2ca850eb218041488dEric Christopher AddGnuCPlusPlusIncludePaths( 836fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth "/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.4/include/g++-v4", 837fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth "x86_64-pc-linux-gnu", "32", "", triple); 83870d9d4196e6531926ca18b2ca850eb218041488dEric Christopher // Gentoo amd64 gcc 4.4.3 83970d9d4196e6531926ca18b2ca850eb218041488dEric Christopher AddGnuCPlusPlusIncludePaths( 84070d9d4196e6531926ca18b2ca850eb218041488dEric Christopher "/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.3/include/g++-v4", 84170d9d4196e6531926ca18b2ca850eb218041488dEric Christopher "x86_64-pc-linux-gnu", "32", "", triple); 842fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth // Gentoo amd64 gcc 4.3.2 8438ad8a1cc1e39d70345d45ef1b8564ec6cbf49471Nico Weber AddGnuCPlusPlusIncludePaths( 844fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth "/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/include/g++-v4", 845fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth "x86_64-pc-linux-gnu", "", "", triple); 846fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth // Gentoo amd64 stable 847fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth AddGnuCPlusPlusIncludePaths( 848fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth "/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/include/g++-v4", 8495370383567e32c840b728bd5d066db281710f2c1Douglas Gregor "x86_64-pc-linux-gnu", "", "", triple); 8508ad8a1cc1e39d70345d45ef1b8564ec6cbf49471Nico Weber 8516693534adb31fdd13b1ee873df3e90c99f916ad5Nick Lewycky // Gentoo amd64 llvm-gcc trunk 8526693534adb31fdd13b1ee873df3e90c99f916ad5Nick Lewycky AddGnuCPlusPlusIncludePaths( 8536693534adb31fdd13b1ee873df3e90c99f916ad5Nick Lewycky "/usr/lib/llvm-gcc-4.2-9999/include/c++/4.2.1", 8546693534adb31fdd13b1ee873df3e90c99f916ad5Nick Lewycky "x86_64-pc-linux-gnu", "", "", triple); 855fbfdb202405df65e054db4ad2111393c1b581d2dChandler Carruth 856e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola break; 857e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola case llvm::Triple::FreeBSD: 858ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // FreeBSD 8.0 859ac78b7a7af0e67f2f4f45d9d94393c281ff4417bmike-m // FreeBSD 7.3 860afe859a9a6217f177daf42ebab294a90bfe8a6abNuno Lopes AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2", "", "", "", triple); 861e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola break; 862ab079419ff2e52652be349e949202a2470f8d253Anton Korobeynikov case llvm::Triple::NetBSD: 863ab079419ff2e52652be349e949202a2470f8d253Anton Korobeynikov AddGnuCPlusPlusIncludePaths("/usr/include/g++", "", "", "", triple); 864ab079419ff2e52652be349e949202a2470f8d253Anton Korobeynikov break; 86595c0457054518102af6250e718a13a5b2ee5dbeaDaniel Dunbar case llvm::Triple::OpenBSD: { 86695c0457054518102af6250e718a13a5b2ee5dbeaDaniel Dunbar std::string t = triple.getTriple(); 86795c0457054518102af6250e718a13a5b2ee5dbeaDaniel Dunbar if (t.substr(0, 6) == "x86_64") 86895c0457054518102af6250e718a13a5b2ee5dbeaDaniel Dunbar t.replace(0, 6, "amd64"); 86995c0457054518102af6250e718a13a5b2ee5dbeaDaniel Dunbar AddGnuCPlusPlusIncludePaths("/usr/include/g++", 87095c0457054518102af6250e718a13a5b2ee5dbeaDaniel Dunbar t, "", "", triple); 87195c0457054518102af6250e718a13a5b2ee5dbeaDaniel Dunbar break; 87295c0457054518102af6250e718a13a5b2ee5dbeaDaniel Dunbar } 87338e317d6dce161b249508686cc67eb7176958762Chris Lattner case llvm::Triple::Minix: 87438e317d6dce161b249508686cc67eb7176958762Chris Lattner AddGnuCPlusPlusIncludePaths("/usr/gnu/include/c++/4.4.3", 87538e317d6dce161b249508686cc67eb7176958762Chris Lattner "", "", "", triple); 87638e317d6dce161b249508686cc67eb7176958762Chris Lattner break; 877e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola case llvm::Triple::Solaris: 878e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola // Solaris - Fall though.. 879e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola case llvm::Triple::AuroraUX: 880e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola // AuroraUX 881e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola AddGnuCPlusPlusIncludePaths("/opt/gcc4/include/c++/4.2.4", 882ab7ae95c46f288ac52974aa60334a9575f9a850cRafael Espindola "i386-pc-solaris2.11", "", "", triple); 883e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola break; 884e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola default: 885e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola break; 886e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola } 887e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola} 888e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola 889e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindolavoid InitHeaderSearch::AddDefaultSystemIncludePaths(const LangOptions &Lang, 8904c2bcad7b843c10fd4a2ffd43da40bfefb4dc8baDouglas Gregor const llvm::Triple &triple, 89179bc57c074cb91f574fba19215f95b63dcf6b04bmike-m const HeaderSearchOptions &HSOpts) { 8920bb208c91e91e2fe91e0f487b00ff4b5b30c8cc2Joerg Sonnenberger if (Lang.CPlusPlus && HSOpts.UseStandardCXXIncludes) 8930bb208c91e91e2fe91e0f487b00ff4b5b30c8cc2Joerg Sonnenberger AddDefaultCPlusPlusIncludePaths(triple); 8946ec18a3f86c702004af66cce6ff979999a736898Rafael Espindola 89579bc57c074cb91f574fba19215f95b63dcf6b04bmike-m AddDefaultCIncludePaths(triple, HSOpts); 896e166582f8f36f4db8f4ea157538fab7fe6bf2658Daniel Dunbar 897e166582f8f36f4db8f4ea157538fab7fe6bf2658Daniel Dunbar // Add the default framework include paths on Darwin. 898db57a4cdb0a6abf3239f3a794a900ce312c5887bDaniel Dunbar if (triple.isOSDarwin()) { 899e166582f8f36f4db8f4ea157538fab7fe6bf2658Daniel Dunbar AddPath("/System/Library/Frameworks", System, true, false, true); 900e166582f8f36f4db8f4ea157538fab7fe6bf2658Daniel Dunbar AddPath("/Library/Frameworks", System, true, false, true); 901e166582f8f36f4db8f4ea157538fab7fe6bf2658Daniel Dunbar } 902e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola} 903e4b255c80a786c6f16d3f0362ecb7e1b1e959f63Rafael Espindola 9040fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber/// RemoveDuplicates - If there are duplicate directory entries in the specified 9050fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber/// search list, remove the later (dead) ones. 9060fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weberstatic void RemoveDuplicates(std::vector<DirectoryLookup> &SearchList, 9072df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger unsigned First, bool Verbose) { 9080fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber llvm::SmallPtrSet<const DirectoryEntry *, 8> SeenDirs; 9090fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber llvm::SmallPtrSet<const DirectoryEntry *, 8> SeenFrameworkDirs; 9100fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber llvm::SmallPtrSet<const HeaderMap *, 8> SeenHeaderMaps; 9112df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger for (unsigned i = First; i != SearchList.size(); ++i) { 9127a739401983eb9bc25c9b4b25177e116f5e5ba92Chris Lattner unsigned DirToRemove = i; 9131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 91443eee07270bf1966ea7289310066aa670c4b647fChris Lattner const DirectoryLookup &CurEntry = SearchList[i]; 9151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 91643eee07270bf1966ea7289310066aa670c4b647fChris Lattner if (CurEntry.isNormalDir()) { 9170fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // If this isn't the first time we've seen this dir, remove it. 91843eee07270bf1966ea7289310066aa670c4b647fChris Lattner if (SeenDirs.insert(CurEntry.getDir())) 9190fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber continue; 92043eee07270bf1966ea7289310066aa670c4b647fChris Lattner } else if (CurEntry.isFramework()) { 9210fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // If this isn't the first time we've seen this framework dir, remove it. 92243eee07270bf1966ea7289310066aa670c4b647fChris Lattner if (SeenFrameworkDirs.insert(CurEntry.getFrameworkDir())) 9230fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber continue; 9240fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } else { 92543eee07270bf1966ea7289310066aa670c4b647fChris Lattner assert(CurEntry.isHeaderMap() && "Not a headermap or normal dir?"); 9260fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // If this isn't the first time we've seen this headermap, remove it. 92743eee07270bf1966ea7289310066aa670c4b647fChris Lattner if (SeenHeaderMaps.insert(CurEntry.getHeaderMap())) 9280fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber continue; 92930f05b553db067c994966daca37e75324ee7b424Chris Lattner } 9301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 93130f05b553db067c994966daca37e75324ee7b424Chris Lattner // If we have a normal #include dir/framework/headermap that is shadowed 93230f05b553db067c994966daca37e75324ee7b424Chris Lattner // later in the chain by a system include location, we actually want to 93330f05b553db067c994966daca37e75324ee7b424Chris Lattner // ignore the user's request and drop the user dir... keeping the system 93430f05b553db067c994966daca37e75324ee7b424Chris Lattner // dir. This is weird, but required to emulate GCC's search path correctly. 93530f05b553db067c994966daca37e75324ee7b424Chris Lattner // 93630f05b553db067c994966daca37e75324ee7b424Chris Lattner // Since dupes of system dirs are rare, just rescan to find the original 93730f05b553db067c994966daca37e75324ee7b424Chris Lattner // that we're nuking instead of using a DenseMap. 93843eee07270bf1966ea7289310066aa670c4b647fChris Lattner if (CurEntry.getDirCharacteristic() != SrcMgr::C_User) { 93930f05b553db067c994966daca37e75324ee7b424Chris Lattner // Find the dir that this is the same of. 94030f05b553db067c994966daca37e75324ee7b424Chris Lattner unsigned FirstDir; 94130f05b553db067c994966daca37e75324ee7b424Chris Lattner for (FirstDir = 0; ; ++FirstDir) { 94230f05b553db067c994966daca37e75324ee7b424Chris Lattner assert(FirstDir != i && "Didn't find dupe?"); 9431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 94443eee07270bf1966ea7289310066aa670c4b647fChris Lattner const DirectoryLookup &SearchEntry = SearchList[FirstDir]; 94543eee07270bf1966ea7289310066aa670c4b647fChris Lattner 94630f05b553db067c994966daca37e75324ee7b424Chris Lattner // If these are different lookup types, then they can't be the dupe. 94743eee07270bf1966ea7289310066aa670c4b647fChris Lattner if (SearchEntry.getLookupType() != CurEntry.getLookupType()) 94830f05b553db067c994966daca37e75324ee7b424Chris Lattner continue; 9491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 95030f05b553db067c994966daca37e75324ee7b424Chris Lattner bool isSame; 95143eee07270bf1966ea7289310066aa670c4b647fChris Lattner if (CurEntry.isNormalDir()) 95243eee07270bf1966ea7289310066aa670c4b647fChris Lattner isSame = SearchEntry.getDir() == CurEntry.getDir(); 95343eee07270bf1966ea7289310066aa670c4b647fChris Lattner else if (CurEntry.isFramework()) 95443eee07270bf1966ea7289310066aa670c4b647fChris Lattner isSame = SearchEntry.getFrameworkDir() == CurEntry.getFrameworkDir(); 95530f05b553db067c994966daca37e75324ee7b424Chris Lattner else { 95643eee07270bf1966ea7289310066aa670c4b647fChris Lattner assert(CurEntry.isHeaderMap() && "Not a headermap or normal dir?"); 95743eee07270bf1966ea7289310066aa670c4b647fChris Lattner isSame = SearchEntry.getHeaderMap() == CurEntry.getHeaderMap(); 95830f05b553db067c994966daca37e75324ee7b424Chris Lattner } 9591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 96030f05b553db067c994966daca37e75324ee7b424Chris Lattner if (isSame) 96130f05b553db067c994966daca37e75324ee7b424Chris Lattner break; 96230f05b553db067c994966daca37e75324ee7b424Chris Lattner } 9631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 96430f05b553db067c994966daca37e75324ee7b424Chris Lattner // If the first dir in the search path is a non-system dir, zap it 96530f05b553db067c994966daca37e75324ee7b424Chris Lattner // instead of the system one. 96630f05b553db067c994966daca37e75324ee7b424Chris Lattner if (SearchList[FirstDir].getDirCharacteristic() == SrcMgr::C_User) 96730f05b553db067c994966daca37e75324ee7b424Chris Lattner DirToRemove = FirstDir; 96830f05b553db067c994966daca37e75324ee7b424Chris Lattner } 96930f05b553db067c994966daca37e75324ee7b424Chris Lattner 97030f05b553db067c994966daca37e75324ee7b424Chris Lattner if (Verbose) { 971e7cb7e4570842297f698bd7fd8d85520fc008acdDaniel Dunbar llvm::errs() << "ignoring duplicate directory \"" 972e7cb7e4570842297f698bd7fd8d85520fc008acdDaniel Dunbar << CurEntry.getName() << "\"\n"; 97330f05b553db067c994966daca37e75324ee7b424Chris Lattner if (DirToRemove != i) 974e7cb7e4570842297f698bd7fd8d85520fc008acdDaniel Dunbar llvm::errs() << " as it is a non-system directory that duplicates " 975e7cb7e4570842297f698bd7fd8d85520fc008acdDaniel Dunbar << "a system directory\n"; 9760fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 9771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 9787a739401983eb9bc25c9b4b25177e116f5e5ba92Chris Lattner // This is reached if the current entry is a duplicate. Remove the 9797a739401983eb9bc25c9b4b25177e116f5e5ba92Chris Lattner // DirToRemove (usually the current dir). 9807a739401983eb9bc25c9b4b25177e116f5e5ba92Chris Lattner SearchList.erase(SearchList.begin()+DirToRemove); 9810fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber --i; 9820fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 9830fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber} 9840fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber 9850fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber 9862df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenbergervoid InitHeaderSearch::Realize(const LangOptions &Lang) { 9870fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // Concatenate ANGLE+SYSTEM+AFTER chains together into SearchList. 9880fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber std::vector<DirectoryLookup> SearchList; 9892df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger SearchList.reserve(IncludePath.size()); 9901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 9912df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger /* Quoted arguments go first. */ 9922df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger for (path_iterator it = IncludePath.begin(), ie = IncludePath.end(); 9932df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger it != ie; ++it) { 9942df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger if (it->first == Quoted) 9952df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger SearchList.push_back(it->second); 9962df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger } 9972df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger /* Deduplicate and remember index */ 9982df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger RemoveDuplicates(SearchList, 0, Verbose); 9992df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger unsigned quoted = SearchList.size(); 10002df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger 10012df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger for (path_iterator it = IncludePath.begin(), ie = IncludePath.end(); 10022df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger it != ie; ++it) { 10032df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger if (it->first == Angled) 10042df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger SearchList.push_back(it->second); 10052df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger } 10062df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger 10072df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger for (path_iterator it = IncludePath.begin(), ie = IncludePath.end(); 10082df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger it != ie; ++it) { 10092df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger if (it->first == System || (Lang.CPlusPlus && it->first == CXXSystem)) 10102df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger SearchList.push_back(it->second); 10112df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger } 10122df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger 10132df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger for (path_iterator it = IncludePath.begin(), ie = IncludePath.end(); 10142df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger it != ie; ++it) { 10152df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger if (it->first == After) 10162df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger SearchList.push_back(it->second); 10172df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger } 10181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 10192df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger RemoveDuplicates(SearchList, quoted, Verbose); 10200fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber 10210fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber bool DontSearchCurDir = false; // TODO: set to true if -I- is set? 10222df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger Headers.SetSearchPaths(SearchList, quoted, DontSearchCurDir); 10230fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber 10240fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber // If verbose, print the list of directories that will be searched. 10250fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber if (Verbose) { 1026e7cb7e4570842297f698bd7fd8d85520fc008acdDaniel Dunbar llvm::errs() << "#include \"...\" search starts here:\n"; 10270fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber for (unsigned i = 0, e = SearchList.size(); i != e; ++i) { 10282df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger if (i == quoted) 1029e7cb7e4570842297f698bd7fd8d85520fc008acdDaniel Dunbar llvm::errs() << "#include <...> search starts here:\n"; 10300fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber const char *Name = SearchList[i].getName(); 10310fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber const char *Suffix; 10320fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber if (SearchList[i].isNormalDir()) 10330fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber Suffix = ""; 10340fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber else if (SearchList[i].isFramework()) 10350fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber Suffix = " (framework directory)"; 10360fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber else { 10370fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber assert(SearchList[i].isHeaderMap() && "Unknown DirectoryLookup"); 10380fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber Suffix = " (headermap)"; 10390fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 1040e7cb7e4570842297f698bd7fd8d85520fc008acdDaniel Dunbar llvm::errs() << " " << Name << Suffix << "\n"; 10410fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 1042e7cb7e4570842297f698bd7fd8d85520fc008acdDaniel Dunbar llvm::errs() << "End of search list.\n"; 10430fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber } 10440fca022d77b89100e746f4d659b84ed5b1ee0158Nico Weber} 104563c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar 10465814e657c9ad9ef6049a2a4af0d2aad248a8a15cDaniel Dunbarvoid clang::ApplyHeaderSearchOptions(HeaderSearch &HS, 10475814e657c9ad9ef6049a2a4af0d2aad248a8a15cDaniel Dunbar const HeaderSearchOptions &HSOpts, 10485814e657c9ad9ef6049a2a4af0d2aad248a8a15cDaniel Dunbar const LangOptions &Lang, 104963c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar const llvm::Triple &Triple) { 105063c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar InitHeaderSearch Init(HS, HSOpts.Verbose, HSOpts.Sysroot); 105163c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar 105263c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar // Add the user defined entries. 105363c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar for (unsigned i = 0, e = HSOpts.UserEntries.size(); i != e; ++i) { 105463c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar const HeaderSearchOptions::Entry &E = HSOpts.UserEntries[i]; 10551b483e70ad3f670f6dd0bc62dbe0921a28195f24Daniel Dunbar Init.AddPath(E.Path, E.Group, false, E.IsUserSupplied, E.IsFramework, 105623637beead1fce7dac755890c9482bcdce538b87Chris Lattner !E.IsSysRootRelative); 105763c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar } 105863c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar 105963c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar // Add entries from CPATH and friends. 10609e9ddf6100fd50ca2f9f9d0106b856e20b43300fBenjamin Kramer Init.AddDelimitedPaths(HSOpts.EnvIncPath); 1061c363cb1929c7908c8c8c4b77d025c2ccb09284aeDaniel Dunbar if (Lang.CPlusPlus && Lang.ObjC1) 10629e9ddf6100fd50ca2f9f9d0106b856e20b43300fBenjamin Kramer Init.AddDelimitedPaths(HSOpts.ObjCXXEnvIncPath); 1063c363cb1929c7908c8c8c4b77d025c2ccb09284aeDaniel Dunbar else if (Lang.CPlusPlus) 10649e9ddf6100fd50ca2f9f9d0106b856e20b43300fBenjamin Kramer Init.AddDelimitedPaths(HSOpts.CXXEnvIncPath); 1065c363cb1929c7908c8c8c4b77d025c2ccb09284aeDaniel Dunbar else if (Lang.ObjC1) 10669e9ddf6100fd50ca2f9f9d0106b856e20b43300fBenjamin Kramer Init.AddDelimitedPaths(HSOpts.ObjCEnvIncPath); 1067c363cb1929c7908c8c8c4b77d025c2ccb09284aeDaniel Dunbar else 10689e9ddf6100fd50ca2f9f9d0106b856e20b43300fBenjamin Kramer Init.AddDelimitedPaths(HSOpts.CEnvIncPath); 106963c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar 1070dd35ce9a783dea7e6660f9cb1d973742f3b3c73fDaniel Dunbar if (HSOpts.UseStandardIncludes) 107179bc57c074cb91f574fba19215f95b63dcf6b04bmike-m Init.AddDefaultSystemIncludePaths(Lang, Triple, HSOpts); 107263c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar 10732df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger Init.Realize(Lang); 107463c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar} 1075