blob: 60c3e9c4d0b8d298e8c6e228b8121fbc371ee8c9 [file] [log] [blame]
Nick Lewyckydf22c2c2010-07-25 03:12:58 +00001//===--- InitHeaderSearch.cpp - Initialize header search paths ------------===//
Nico Weber0fca0222008-08-22 09:25:22 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the InitHeaderSearch class.
11//
12//===----------------------------------------------------------------------===//
13
Oscar Fuentes2100fe92011-02-03 22:48:20 +000014#ifdef HAVE_CLANG_CONFIG_H
15# include "clang/Config/config.h"
16#endif
17
Daniel Dunbar2cdafa82009-11-09 23:02:47 +000018#include "clang/Frontend/Utils.h"
Nico Weber0fca0222008-08-22 09:25:22 +000019#include "clang/Basic/FileManager.h"
20#include "clang/Basic/LangOptions.h"
Daniel Dunbar63c8b772009-11-07 04:20:50 +000021#include "clang/Frontend/HeaderSearchOptions.h"
22#include "clang/Lex/HeaderSearch.h"
Nico Weber0fca0222008-08-22 09:25:22 +000023#include "llvm/ADT/SmallString.h"
24#include "llvm/ADT/SmallPtrSet.h"
Rafael Espindolaaadd7a42009-11-13 05:13:58 +000025#include "llvm/ADT/SmallVector.h"
Rafael Espindolaf0a2f512009-11-12 05:48:41 +000026#include "llvm/ADT/StringExtras.h"
Daniel Dunbar2cdafa82009-11-09 23:02:47 +000027#include "llvm/ADT/Triple.h"
Benjamin Kramere89ba592009-12-08 12:38:20 +000028#include "llvm/ADT/Twine.h"
Chris Lattnerd57a7ef2009-08-23 22:45:33 +000029#include "llvm/Support/raw_ostream.h"
Michael J. Spencer03013fa2010-11-29 18:12:39 +000030#include "llvm/Support/Path.h"
Argyrios Kyrtzidis121e3c22008-09-05 09:41:20 +000031#include "llvm/Config/config.h"
Mike Stump620d57a2009-10-12 20:50:45 +000032#ifdef _MSC_VER
33 #define WIN32_LEAN_AND_MEAN 1
34 #include <windows.h>
35#endif
Nico Weber0fca0222008-08-22 09:25:22 +000036using namespace clang;
Daniel Dunbar2cdafa82009-11-09 23:02:47 +000037using namespace clang::frontend;
38
39namespace {
40
41/// InitHeaderSearch - This class makes it easier to set the search paths of
42/// a HeaderSearch object. InitHeaderSearch stores several search path lists
43/// internally, which can be sent to a HeaderSearch object in one swoop.
44class InitHeaderSearch {
Joerg Sonnenberger2df66472011-02-22 00:40:56 +000045 std::vector<std::pair<IncludeDirGroup, DirectoryLookup> > IncludePath;
46 typedef std::vector<std::pair<IncludeDirGroup,
47 DirectoryLookup> >::const_iterator path_iterator;
Daniel Dunbar2cdafa82009-11-09 23:02:47 +000048 HeaderSearch& Headers;
49 bool Verbose;
Michael J. Spenceraf6530c2010-12-25 20:09:27 +000050 std::string IncludeSysroot;
51 bool IsNotEmptyOrRoot;
Daniel Dunbar2cdafa82009-11-09 23:02:47 +000052
53public:
54
Chandler Carruthc09265a2010-11-15 07:15:26 +000055 InitHeaderSearch(HeaderSearch &HS, bool verbose, llvm::StringRef sysroot)
Michael J. Spenceraf6530c2010-12-25 20:09:27 +000056 : Headers(HS), Verbose(verbose), IncludeSysroot(sysroot),
57 IsNotEmptyOrRoot(!(sysroot.empty() || sysroot == "/")) {
Chandler Carruthc09265a2010-11-15 07:15:26 +000058 }
Daniel Dunbar2cdafa82009-11-09 23:02:47 +000059
60 /// AddPath - Add the specified path to the specified group list.
Benjamin Kramere89ba592009-12-08 12:38:20 +000061 void AddPath(const llvm::Twine &Path, IncludeDirGroup Group,
Daniel Dunbar2cdafa82009-11-09 23:02:47 +000062 bool isCXXAware, bool isUserSupplied,
63 bool isFramework, bool IgnoreSysRoot = false);
64
mike-ma6087372010-05-05 17:00:31 +000065 /// AddGnuCPlusPlusIncludePaths - Add the necessary paths to support a gnu
Daniel Dunbar2cdafa82009-11-09 23:02:47 +000066 /// libstdc++.
Benjamin Kramere89ba592009-12-08 12:38:20 +000067 void AddGnuCPlusPlusIncludePaths(llvm::StringRef Base,
68 llvm::StringRef ArchDir,
69 llvm::StringRef Dir32,
70 llvm::StringRef Dir64,
Daniel Dunbar2cdafa82009-11-09 23:02:47 +000071 const llvm::Triple &triple);
72
Michael J. Spencer06a8dc62010-12-21 16:45:42 +000073 /// AddMinGWCPlusPlusIncludePaths - Add the necessary paths to support a MinGW
Daniel Dunbar2cdafa82009-11-09 23:02:47 +000074 /// libstdc++.
Benjamin Kramere89ba592009-12-08 12:38:20 +000075 void AddMinGWCPlusPlusIncludePaths(llvm::StringRef Base,
76 llvm::StringRef Arch,
77 llvm::StringRef Version);
Daniel Dunbar2cdafa82009-11-09 23:02:47 +000078
79 /// AddDelimitedPaths - Add a list of paths delimited by the system PATH
80 /// separator. The processing follows that of the CPATH variable for gcc.
Benjamin Kramer9e9ddf62009-12-08 12:11:06 +000081 void AddDelimitedPaths(llvm::StringRef String);
Daniel Dunbar2cdafa82009-11-09 23:02:47 +000082
83 // AddDefaultCIncludePaths - Add paths that should always be searched.
mike-m79bc57c2010-05-16 19:03:52 +000084 void AddDefaultCIncludePaths(const llvm::Triple &triple,
85 const HeaderSearchOptions &HSOpts);
Daniel Dunbar2cdafa82009-11-09 23:02:47 +000086
87 // AddDefaultCPlusPlusIncludePaths - Add paths that should be searched when
88 // compiling c++.
89 void AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple);
90
91 /// AddDefaultSystemIncludePaths - Adds the default system include paths so
92 /// that e.g. stdio.h is found.
93 void AddDefaultSystemIncludePaths(const LangOptions &Lang,
Douglas Gregor4c2bcad2010-03-24 20:13:48 +000094 const llvm::Triple &triple,
mike-m79bc57c2010-05-16 19:03:52 +000095 const HeaderSearchOptions &HSOpts);
Daniel Dunbar2cdafa82009-11-09 23:02:47 +000096
97 /// Realize - Merges all search path lists into one list and send it to
98 /// HeaderSearch.
Joerg Sonnenberger2df66472011-02-22 00:40:56 +000099 void Realize(const LangOptions &Lang);
Daniel Dunbar2cdafa82009-11-09 23:02:47 +0000100};
101
102}
Nico Weber0fca0222008-08-22 09:25:22 +0000103
Benjamin Kramere89ba592009-12-08 12:38:20 +0000104void InitHeaderSearch::AddPath(const llvm::Twine &Path,
Benjamin Kramer458fb102009-09-05 09:49:39 +0000105 IncludeDirGroup Group, bool isCXXAware,
106 bool isUserSupplied, bool isFramework,
107 bool IgnoreSysRoot) {
Benjamin Kramere89ba592009-12-08 12:38:20 +0000108 assert(!Path.isTriviallyEmpty() && "can't handle empty path here");
Nico Weber0fca0222008-08-22 09:25:22 +0000109 FileManager &FM = Headers.getFileMgr();
Mike Stump1eb44332009-09-09 15:08:12 +0000110
Nico Weber0fca0222008-08-22 09:25:22 +0000111 // Compute the actual path, taking into consideration -isysroot.
Chandler Carruth5853b0f2010-11-15 00:05:18 +0000112 llvm::SmallString<256> MappedPathStorage;
Chandler Carruthf3721452010-11-15 00:48:13 +0000113 llvm::StringRef MappedPathStr = Path.toStringRef(MappedPathStorage);
Mike Stump1eb44332009-09-09 15:08:12 +0000114
Nico Weber0fca0222008-08-22 09:25:22 +0000115 // Handle isysroot.
Rafael Espindola9a7e09d2011-03-02 21:30:07 +0000116 if ((Group == System || Group == CXXSystem) && !IgnoreSysRoot &&
Michael J. Spencer256053b2010-12-17 21:22:22 +0000117 llvm::sys::path::is_absolute(MappedPathStr) &&
Michael J. Spenceraf6530c2010-12-25 20:09:27 +0000118 IsNotEmptyOrRoot) {
Chandler Carruth5619ae52010-11-15 09:28:23 +0000119 MappedPathStorage.clear();
Chandler Carruthc09265a2010-11-15 07:15:26 +0000120 MappedPathStr =
Michael J. Spenceraf6530c2010-12-25 20:09:27 +0000121 (IncludeSysroot + Path).toStringRef(MappedPathStorage);
Nico Weber0fca0222008-08-22 09:25:22 +0000122 }
Mike Stump1eb44332009-09-09 15:08:12 +0000123
Nico Weber0fca0222008-08-22 09:25:22 +0000124 // Compute the DirectoryLookup type.
Chris Lattner9d728512008-10-27 01:19:25 +0000125 SrcMgr::CharacteristicKind Type;
Nico Weber0fca0222008-08-22 09:25:22 +0000126 if (Group == Quoted || Group == Angled)
Chris Lattner0b9e7362008-09-26 21:18:42 +0000127 Type = SrcMgr::C_User;
Nico Weber0fca0222008-08-22 09:25:22 +0000128 else if (isCXXAware)
Chris Lattner0b9e7362008-09-26 21:18:42 +0000129 Type = SrcMgr::C_System;
Nico Weber0fca0222008-08-22 09:25:22 +0000130 else
Chris Lattner0b9e7362008-09-26 21:18:42 +0000131 Type = SrcMgr::C_ExternCSystem;
Mike Stump1eb44332009-09-09 15:08:12 +0000132
133
Nico Weber0fca0222008-08-22 09:25:22 +0000134 // If the directory exists, add it.
Chris Lattner39b49bc2010-11-23 08:35:12 +0000135 if (const DirectoryEntry *DE = FM.getDirectory(MappedPathStr)) {
Joerg Sonnenberger2df66472011-02-22 00:40:56 +0000136 IncludePath.push_back(std::make_pair(Group, DirectoryLookup(DE, Type,
137 isUserSupplied, isFramework)));
Nico Weber0fca0222008-08-22 09:25:22 +0000138 return;
139 }
Mike Stump1eb44332009-09-09 15:08:12 +0000140
Nico Weber0fca0222008-08-22 09:25:22 +0000141 // Check to see if this is an apple-style headermap (which are not allowed to
142 // be frameworks).
143 if (!isFramework) {
Chris Lattner39b49bc2010-11-23 08:35:12 +0000144 if (const FileEntry *FE = FM.getFile(MappedPathStr)) {
Nico Weber0fca0222008-08-22 09:25:22 +0000145 if (const HeaderMap *HM = Headers.CreateHeaderMap(FE)) {
146 // It is a headermap, add it to the search path.
Joerg Sonnenberger2df66472011-02-22 00:40:56 +0000147 IncludePath.push_back(std::make_pair(Group, DirectoryLookup(HM, Type,
148 isUserSupplied)));
Nico Weber0fca0222008-08-22 09:25:22 +0000149 return;
150 }
151 }
152 }
Mike Stump1eb44332009-09-09 15:08:12 +0000153
Nico Weber0fca0222008-08-22 09:25:22 +0000154 if (Verbose)
Chandler Carruthf3721452010-11-15 00:48:13 +0000155 llvm::errs() << "ignoring nonexistent directory \""
156 << MappedPathStr << "\"\n";
Nico Weber0fca0222008-08-22 09:25:22 +0000157}
158
159
Benjamin Kramer9e9ddf62009-12-08 12:11:06 +0000160void InitHeaderSearch::AddDelimitedPaths(llvm::StringRef at) {
161 if (at.empty()) // Empty string should not add '.' path.
Nico Weber0fca0222008-08-22 09:25:22 +0000162 return;
163
Benjamin Kramer9e9ddf62009-12-08 12:11:06 +0000164 llvm::StringRef::size_type delim;
165 while ((delim = at.find(llvm::sys::PathSeparator)) != llvm::StringRef::npos) {
166 if (delim == 0)
Nico Weber0fca0222008-08-22 09:25:22 +0000167 AddPath(".", Angled, false, true, false);
168 else
Benjamin Kramer9e9ddf62009-12-08 12:11:06 +0000169 AddPath(at.substr(0, delim), Angled, false, true, false);
170 at = at.substr(delim + 1);
Nico Weber0fca0222008-08-22 09:25:22 +0000171 }
Benjamin Kramer9e9ddf62009-12-08 12:11:06 +0000172
173 if (at.empty())
Nico Weber0fca0222008-08-22 09:25:22 +0000174 AddPath(".", Angled, false, true, false);
175 else
176 AddPath(at, Angled, false, true, false);
177}
178
Benjamin Kramere89ba592009-12-08 12:38:20 +0000179void InitHeaderSearch::AddGnuCPlusPlusIncludePaths(llvm::StringRef Base,
180 llvm::StringRef ArchDir,
181 llvm::StringRef Dir32,
182 llvm::StringRef Dir64,
Rafael Espindola31b63be2009-10-14 17:09:44 +0000183 const llvm::Triple &triple) {
Rafael Espindola6ec18a32009-11-23 16:31:19 +0000184 // Add the base dir
Joerg Sonnenberger2df66472011-02-22 00:40:56 +0000185 AddPath(Base, CXXSystem, true, false, false);
Rafael Espindolaab7ae952009-11-16 19:49:37 +0000186
187 // Add the multilib dirs
Rafael Espindola31b63be2009-10-14 17:09:44 +0000188 llvm::Triple::ArchType arch = triple.getArch();
189 bool is64bit = arch == llvm::Triple::ppc64 || arch == llvm::Triple::x86_64;
Rafael Espindola31b63be2009-10-14 17:09:44 +0000190 if (is64bit)
Joerg Sonnenberger2df66472011-02-22 00:40:56 +0000191 AddPath(Base + "/" + ArchDir + "/" + Dir64, CXXSystem, true, false, false);
Rafael Espindola31b63be2009-10-14 17:09:44 +0000192 else
Joerg Sonnenberger2df66472011-02-22 00:40:56 +0000193 AddPath(Base + "/" + ArchDir + "/" + Dir32, CXXSystem, true, false, false);
Rafael Espindola6ec18a32009-11-23 16:31:19 +0000194
195 // Add the backward dir
Joerg Sonnenberger2df66472011-02-22 00:40:56 +0000196 AddPath(Base + "/backward", CXXSystem, true, false, false);
Rafael Espindola2e9f6522009-10-06 01:33:02 +0000197}
Nico Weber0fca0222008-08-22 09:25:22 +0000198
Benjamin Kramere89ba592009-12-08 12:38:20 +0000199void InitHeaderSearch::AddMinGWCPlusPlusIncludePaths(llvm::StringRef Base,
200 llvm::StringRef Arch,
201 llvm::StringRef Version) {
Benjamin Kramerab8ae192010-01-20 16:18:11 +0000202 AddPath(Base + "/" + Arch + "/" + Version + "/include/c++",
Joerg Sonnenberger2df66472011-02-22 00:40:56 +0000203 CXXSystem, true, false, false);
Chris Lattner8e9006b2010-09-03 16:45:53 +0000204 AddPath(Base + "/" + Arch + "/" + Version + "/include/c++/" + Arch,
Joerg Sonnenberger2df66472011-02-22 00:40:56 +0000205 CXXSystem, true, false, false);
Benjamin Kramerab8ae192010-01-20 16:18:11 +0000206 AddPath(Base + "/" + Arch + "/" + Version + "/include/c++/backward",
Joerg Sonnenberger2df66472011-02-22 00:40:56 +0000207 CXXSystem, true, false, false);
Mike Stump620d57a2009-10-12 20:50:45 +0000208}
Argyrios Kyrtzidis121e3c22008-09-05 09:41:20 +0000209
Mike Stump620d57a2009-10-12 20:50:45 +0000210 // FIXME: This probably should goto to some platform utils place.
211#ifdef _MSC_VER
John Thompson75ee3bd2009-11-21 00:15:52 +0000212
Mike Stump620d57a2009-10-12 20:50:45 +0000213 // Read registry string.
John Thompson75ee3bd2009-11-21 00:15:52 +0000214 // This also supports a means to look for high-versioned keys by use
215 // of a $VERSION placeholder in the key path.
216 // $VERSION in the key path is a placeholder for the version number,
217 // causing the highest value path to be searched for and used.
218 // I.e. "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\$VERSION".
219 // There can be additional characters in the component. Only the numberic
220 // characters are compared.
Benjamin Kramer6cd52162010-01-20 16:21:40 +0000221static bool getSystemRegistryString(const char *keyPath, const char *valueName,
222 char *value, size_t maxLength) {
Mike Stump43d81762009-10-08 23:29:47 +0000223 HKEY hRootKey = NULL;
224 HKEY hKey = NULL;
225 const char* subKey = NULL;
226 DWORD valueType;
227 DWORD valueSize = maxLength - 1;
John Thompson75ee3bd2009-11-21 00:15:52 +0000228 long lResult;
Mike Stump43d81762009-10-08 23:29:47 +0000229 bool returnValue = false;
230 if (strncmp(keyPath, "HKEY_CLASSES_ROOT\\", 18) == 0) {
231 hRootKey = HKEY_CLASSES_ROOT;
232 subKey = keyPath + 18;
Argyrios Kyrtzidis121e3c22008-09-05 09:41:20 +0000233 }
Mike Stump43d81762009-10-08 23:29:47 +0000234 else if (strncmp(keyPath, "HKEY_USERS\\", 11) == 0) {
235 hRootKey = HKEY_USERS;
236 subKey = keyPath + 11;
237 }
238 else if (strncmp(keyPath, "HKEY_LOCAL_MACHINE\\", 19) == 0) {
239 hRootKey = HKEY_LOCAL_MACHINE;
240 subKey = keyPath + 19;
241 }
242 else if (strncmp(keyPath, "HKEY_CURRENT_USER\\", 18) == 0) {
243 hRootKey = HKEY_CURRENT_USER;
244 subKey = keyPath + 18;
245 }
246 else
247 return(false);
John Thompson75ee3bd2009-11-21 00:15:52 +0000248 const char *placeHolder = strstr(subKey, "$VERSION");
249 char bestName[256];
250 bestName[0] = '\0';
251 // If we have a $VERSION placeholder, do the highest-version search.
252 if (placeHolder) {
253 const char *keyEnd = placeHolder - 1;
254 const char *nextKey = placeHolder;
255 // Find end of previous key.
256 while ((keyEnd > subKey) && (*keyEnd != '\\'))
257 keyEnd--;
258 // Find end of key containing $VERSION.
259 while (*nextKey && (*nextKey != '\\'))
260 nextKey++;
261 size_t partialKeyLength = keyEnd - subKey;
262 char partialKey[256];
263 if (partialKeyLength > sizeof(partialKey))
264 partialKeyLength = sizeof(partialKey);
265 strncpy(partialKey, subKey, partialKeyLength);
266 partialKey[partialKeyLength] = '\0';
267 HKEY hTopKey = NULL;
268 lResult = RegOpenKeyEx(hRootKey, partialKey, 0, KEY_READ, &hTopKey);
269 if (lResult == ERROR_SUCCESS) {
270 char keyName[256];
271 int bestIndex = -1;
272 double bestValue = 0.0;
273 DWORD index, size = sizeof(keyName) - 1;
Nuno Lopes33cc2432009-12-07 17:18:48 +0000274 for (index = 0; RegEnumKeyEx(hTopKey, index, keyName, &size, NULL,
275 NULL, NULL, NULL) == ERROR_SUCCESS; index++) {
276 const char *sp = keyName;
277 while (*sp && !isdigit(*sp))
278 sp++;
279 if (!*sp)
280 continue;
281 const char *ep = sp + 1;
282 while (*ep && (isdigit(*ep) || (*ep == '.')))
283 ep++;
284 char numBuf[32];
285 strncpy(numBuf, sp, sizeof(numBuf) - 1);
286 numBuf[sizeof(numBuf) - 1] = '\0';
287 double value = strtod(numBuf, NULL);
288 if (value > bestValue) {
289 bestIndex = (int)index;
290 bestValue = value;
291 strcpy(bestName, keyName);
292 }
John Thompson75ee3bd2009-11-21 00:15:52 +0000293 size = sizeof(keyName) - 1;
294 }
295 // If we found the highest versioned key, open the key and get the value.
296 if (bestIndex != -1) {
297 // Append rest of key.
298 strncat(bestName, nextKey, sizeof(bestName) - 1);
299 bestName[sizeof(bestName) - 1] = '\0';
300 // Open the chosen key path remainder.
301 lResult = RegOpenKeyEx(hTopKey, bestName, 0, KEY_READ, &hKey);
302 if (lResult == ERROR_SUCCESS) {
303 lResult = RegQueryValueEx(hKey, valueName, NULL, &valueType,
304 (LPBYTE)value, &valueSize);
305 if (lResult == ERROR_SUCCESS)
306 returnValue = true;
307 RegCloseKey(hKey);
308 }
309 }
310 RegCloseKey(hTopKey);
311 }
312 }
313 else {
314 lResult = RegOpenKeyEx(hRootKey, subKey, 0, KEY_READ, &hKey);
315 if (lResult == ERROR_SUCCESS) {
316 lResult = RegQueryValueEx(hKey, valueName, NULL, &valueType,
317 (LPBYTE)value, &valueSize);
318 if (lResult == ERROR_SUCCESS)
319 returnValue = true;
320 RegCloseKey(hKey);
321 }
Mike Stump43d81762009-10-08 23:29:47 +0000322 }
323 return(returnValue);
324}
Mike Stump620d57a2009-10-12 20:50:45 +0000325#else // _MSC_VER
326 // Read registry string.
Benjamin Kramer6cd52162010-01-20 16:21:40 +0000327static bool getSystemRegistryString(const char*, const char*, char*, size_t) {
Mike Stump620d57a2009-10-12 20:50:45 +0000328 return(false);
329}
330#endif // _MSC_VER
Argyrios Kyrtzidis121e3c22008-09-05 09:41:20 +0000331
Mike Stump43d81762009-10-08 23:29:47 +0000332 // Get Visual Studio installation directory.
Benjamin Kramer6cd52162010-01-20 16:21:40 +0000333static bool getVisualStudioDir(std::string &path) {
Michael J. Spencerff58e362010-08-21 21:55:07 +0000334 // First check the environment variables that vsvars32.bat sets.
335 const char* vcinstalldir = getenv("VCINSTALLDIR");
336 if(vcinstalldir) {
337 char *p = const_cast<char *>(strstr(vcinstalldir, "\\VC"));
338 if (p)
339 *p = '\0';
340 path = vcinstalldir;
341 return(true);
342 }
343
John Thompson75ee3bd2009-11-21 00:15:52 +0000344 char vsIDEInstallDir[256];
Douglas Gregor80f93d92010-05-18 05:47:04 +0000345 char vsExpressIDEInstallDir[256];
Michael J. Spencerff58e362010-08-21 21:55:07 +0000346 // Then try the windows registry.
John Thompson75ee3bd2009-11-21 00:15:52 +0000347 bool hasVCDir = getSystemRegistryString(
348 "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\$VERSION",
349 "InstallDir", vsIDEInstallDir, sizeof(vsIDEInstallDir) - 1);
Douglas Gregor80f93d92010-05-18 05:47:04 +0000350 bool hasVCExpressDir = getSystemRegistryString(
351 "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\$VERSION",
352 "InstallDir", vsExpressIDEInstallDir, sizeof(vsExpressIDEInstallDir) - 1);
NAKAMURA Takumi125b4cb2011-02-17 08:50:50 +0000353 // If we have both vc80 and vc90, pick version we were compiled with.
John Thompson75ee3bd2009-11-21 00:15:52 +0000354 if (hasVCDir && vsIDEInstallDir[0]) {
Mike Stump620d57a2009-10-12 20:50:45 +0000355 char *p = (char*)strstr(vsIDEInstallDir, "\\Common7\\IDE");
356 if (p)
357 *p = '\0';
358 path = vsIDEInstallDir;
359 return(true);
360 }
Douglas Gregor80f93d92010-05-18 05:47:04 +0000361 else if (hasVCExpressDir && vsExpressIDEInstallDir[0]) {
362 char *p = (char*)strstr(vsExpressIDEInstallDir, "\\Common7\\IDE");
363 if (p)
364 *p = '\0';
365 path = vsExpressIDEInstallDir;
366 return(true);
367 }
Mike Stump620d57a2009-10-12 20:50:45 +0000368 else {
369 // Try the environment.
Douglas Gregor80f93d92010-05-18 05:47:04 +0000370 const char* vs100comntools = getenv("VS100COMNTOOLS");
Mike Stump620d57a2009-10-12 20:50:45 +0000371 const char* vs90comntools = getenv("VS90COMNTOOLS");
372 const char* vs80comntools = getenv("VS80COMNTOOLS");
373 const char* vscomntools = NULL;
Douglas Gregor80f93d92010-05-18 05:47:04 +0000374
NAKAMURA Takumi125b4cb2011-02-17 08:50:50 +0000375 // Try to find the version that we were compiled with
Douglas Gregor80f93d92010-05-18 05:47:04 +0000376 if(false) {}
377 #if (_MSC_VER >= 1600) // VC100
378 else if(vs100comntools) {
379 vscomntools = vs100comntools;
Mike Stump620d57a2009-10-12 20:50:45 +0000380 }
Douglas Gregor80f93d92010-05-18 05:47:04 +0000381 #elif (_MSC_VER == 1500) // VC80
382 else if(vs90comntools) {
383 vscomntools = vs90comntools;
384 }
385 #elif (_MSC_VER == 1400) // VC80
386 else if(vs80comntools) {
387 vscomntools = vs80comntools;
388 }
389 #endif
390 // Otherwise find any version we can
391 else if (vs100comntools)
392 vscomntools = vs100comntools;
Mike Stump620d57a2009-10-12 20:50:45 +0000393 else if (vs90comntools)
Mike Stump43d81762009-10-08 23:29:47 +0000394 vscomntools = vs90comntools;
Mike Stump620d57a2009-10-12 20:50:45 +0000395 else if (vs80comntools)
396 vscomntools = vs80comntools;
Douglas Gregor80f93d92010-05-18 05:47:04 +0000397
Mike Stump620d57a2009-10-12 20:50:45 +0000398 if (vscomntools && *vscomntools) {
Dan Gohmancb421fa2010-04-19 16:39:44 +0000399 char *p = const_cast<char *>(strstr(vscomntools, "\\Common7\\Tools"));
Mike Stump620d57a2009-10-12 20:50:45 +0000400 if (p)
401 *p = '\0';
402 path = vscomntools;
403 return(true);
404 }
405 else
406 return(false);
Mike Stump43d81762009-10-08 23:29:47 +0000407 }
Mike Stump620d57a2009-10-12 20:50:45 +0000408 return(false);
Mike Stump43d81762009-10-08 23:29:47 +0000409}
Mike Stump43d81762009-10-08 23:29:47 +0000410
John Thompson75ee3bd2009-11-21 00:15:52 +0000411 // Get Windows SDK installation directory.
Benjamin Kramer6cd52162010-01-20 16:21:40 +0000412static bool getWindowsSDKDir(std::string &path) {
John Thompson75ee3bd2009-11-21 00:15:52 +0000413 char windowsSDKInstallDir[256];
414 // Try the Windows registry.
415 bool hasSDKDir = getSystemRegistryString(
416 "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\$VERSION",
417 "InstallationFolder", windowsSDKInstallDir, sizeof(windowsSDKInstallDir) - 1);
NAKAMURA Takumi125b4cb2011-02-17 08:50:50 +0000418 // If we have both vc80 and vc90, pick version we were compiled with.
John Thompson75ee3bd2009-11-21 00:15:52 +0000419 if (hasSDKDir && windowsSDKInstallDir[0]) {
420 path = windowsSDKInstallDir;
421 return(true);
422 }
423 return(false);
424}
425
mike-m79bc57c2010-05-16 19:03:52 +0000426void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
427 const HeaderSearchOptions &HSOpts) {
Benjamin Kramer8e50a962011-02-02 18:59:27 +0000428 llvm::Triple::OSType os = triple.getOS();
429
430 switch (os) {
Roman Divacky63076602011-03-01 18:08:03 +0000431 case llvm::Triple::FreeBSD:
Benjamin Kramer8e50a962011-02-02 18:59:27 +0000432 case llvm::Triple::NetBSD:
433 break;
434 default:
435 // FIXME: temporary hack: hard-coded paths.
436 AddPath("/usr/local/include", System, true, false, false);
437 break;
438 }
mike-m79bc57c2010-05-16 19:03:52 +0000439
440 // Builtin includes use #include_next directives and should be positioned
441 // just prior C include dirs.
442 if (HSOpts.UseBuiltinIncludes) {
443 // Ignore the sys root, we *always* look for clang headers relative to
444 // supplied path.
445 llvm::sys::Path P(HSOpts.ResourceDir);
446 P.appendComponent("include");
447 AddPath(P.str(), System, false, false, false, /*IgnoreSysRoot=*/ true);
448 }
449
450 // Add dirs specified via 'configure --with-c-include-dirs'.
Daniel Dunbarc7064682009-11-12 07:28:29 +0000451 llvm::StringRef CIncludeDirs(C_INCLUDE_DIRS);
452 if (CIncludeDirs != "") {
Rafael Espindolaaadd7a42009-11-13 05:13:58 +0000453 llvm::SmallVector<llvm::StringRef, 5> dirs;
454 CIncludeDirs.split(dirs, ":");
455 for (llvm::SmallVectorImpl<llvm::StringRef>::iterator i = dirs.begin();
456 i != dirs.end();
NAKAMURA Takumi125b4cb2011-02-17 08:50:50 +0000457 ++i)
Rafael Espindolaf0a2f512009-11-12 05:48:41 +0000458 AddPath(*i, System, false, false, false);
459 return;
460 }
Benjamin Kramer8e50a962011-02-02 18:59:27 +0000461
Mike Stump43d81762009-10-08 23:29:47 +0000462 switch (os) {
Daniel Dunbard11ee7f2010-09-09 17:38:18 +0000463 case llvm::Triple::Win32: {
464 std::string VSDir;
465 std::string WindowsSDKDir;
466 if (getVisualStudioDir(VSDir)) {
467 AddPath(VSDir + "\\VC\\include", System, false, false, false);
468 if (getWindowsSDKDir(WindowsSDKDir))
469 AddPath(WindowsSDKDir + "\\include", System, false, false, false);
470 else
471 AddPath(VSDir + "\\VC\\PlatformSDK\\Include",
472 System, false, false, false);
473 } else {
474 // Default install paths.
475 AddPath("C:/Program Files/Microsoft Visual Studio 10.0/VC/include",
476 System, false, false, false);
477 AddPath("C:/Program Files/Microsoft Visual Studio 9.0/VC/include",
478 System, false, false, false);
479 AddPath(
John Thompson9319f022009-11-23 17:49:27 +0000480 "C:/Program Files/Microsoft Visual Studio 9.0/VC/PlatformSDK/Include",
Daniel Dunbard11ee7f2010-09-09 17:38:18 +0000481 System, false, false, false);
482 AddPath("C:/Program Files/Microsoft Visual Studio 8/VC/include",
483 System, false, false, false);
484 AddPath(
John Thompson9319f022009-11-23 17:49:27 +0000485 "C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/Include",
Daniel Dunbard11ee7f2010-09-09 17:38:18 +0000486 System, false, false, false);
Mike Stump43d81762009-10-08 23:29:47 +0000487 }
488 break;
Daniel Dunbard11ee7f2010-09-09 17:38:18 +0000489 }
Chris Lattner86ed3a32010-04-11 19:29:39 +0000490 case llvm::Triple::Haiku:
491 AddPath("/boot/common/include", System, true, false, false);
492 AddPath("/boot/develop/headers/os", System, true, false, false);
493 AddPath("/boot/develop/headers/os/app", System, true, false, false);
494 AddPath("/boot/develop/headers/os/arch", System, true, false, false);
495 AddPath("/boot/develop/headers/os/device", System, true, false, false);
496 AddPath("/boot/develop/headers/os/drivers", System, true, false, false);
NAKAMURA Takumi125b4cb2011-02-17 08:50:50 +0000497 AddPath("/boot/develop/headers/os/game", System, true, false, false);
Chris Lattner86ed3a32010-04-11 19:29:39 +0000498 AddPath("/boot/develop/headers/os/interface", System, true, false, false);
499 AddPath("/boot/develop/headers/os/kernel", System, true, false, false);
500 AddPath("/boot/develop/headers/os/locale", System, true, false, false);
501 AddPath("/boot/develop/headers/os/mail", System, true, false, false);
502 AddPath("/boot/develop/headers/os/media", System, true, false, false);
503 AddPath("/boot/develop/headers/os/midi", System, true, false, false);
504 AddPath("/boot/develop/headers/os/midi2", System, true, false, false);
505 AddPath("/boot/develop/headers/os/net", System, true, false, false);
506 AddPath("/boot/develop/headers/os/storage", System, true, false, false);
507 AddPath("/boot/develop/headers/os/support", System, true, false, false);
508 AddPath("/boot/develop/headers/os/translation",
509 System, true, false, false);
NAKAMURA Takumi125b4cb2011-02-17 08:50:50 +0000510 AddPath("/boot/develop/headers/os/add-ons/graphics",
Chris Lattner86ed3a32010-04-11 19:29:39 +0000511 System, true, false, false);
NAKAMURA Takumi125b4cb2011-02-17 08:50:50 +0000512 AddPath("/boot/develop/headers/os/add-ons/input_server",
Chris Lattner86ed3a32010-04-11 19:29:39 +0000513 System, true, false, false);
NAKAMURA Takumi125b4cb2011-02-17 08:50:50 +0000514 AddPath("/boot/develop/headers/os/add-ons/screen_saver",
Chris Lattner86ed3a32010-04-11 19:29:39 +0000515 System, true, false, false);
NAKAMURA Takumi125b4cb2011-02-17 08:50:50 +0000516 AddPath("/boot/develop/headers/os/add-ons/tracker",
Chris Lattner86ed3a32010-04-11 19:29:39 +0000517 System, true, false, false);
518 AddPath("/boot/develop/headers/os/be_apps/Deskbar",
519 System, true, false, false);
520 AddPath("/boot/develop/headers/os/be_apps/NetPositive",
521 System, true, false, false);
522 AddPath("/boot/develop/headers/os/be_apps/Tracker",
523 System, true, false, false);
524 AddPath("/boot/develop/headers/cpp", System, true, false, false);
NAKAMURA Takumi125b4cb2011-02-17 08:50:50 +0000525 AddPath("/boot/develop/headers/cpp/i586-pc-haiku",
Chris Lattner86ed3a32010-04-11 19:29:39 +0000526 System, true, false, false);
527 AddPath("/boot/develop/headers/3rdparty", System, true, false, false);
528 AddPath("/boot/develop/headers/bsd", System, true, false, false);
529 AddPath("/boot/develop/headers/glibc", System, true, false, false);
530 AddPath("/boot/develop/headers/posix", System, true, false, false);
531 AddPath("/boot/develop/headers", System, true, false, false);
Eli Friedmana7e68452010-08-22 01:00:03 +0000532 break;
NAKAMURA Takumi32df0022010-10-11 02:27:37 +0000533 case llvm::Triple::Cygwin:
534 AddPath("/usr/include/w32api", System, true, false, false);
535 break;
Mike Stump620d57a2009-10-12 20:50:45 +0000536 case llvm::Triple::MinGW32:
Douglas Gregorab0d8bd2011-03-06 18:00:59 +0000537 AddPath("/mingw/include", System, true, false, false);
Mike Stump43d81762009-10-08 23:29:47 +0000538 AddPath("c:/mingw/include", System, true, false, false);
539 break;
540 default:
Mike Stump43d81762009-10-08 23:29:47 +0000541 break;
542 }
John Thompsond3f88342009-10-13 18:51:32 +0000543
John Thompsond3f88342009-10-13 18:51:32 +0000544 AddPath("/usr/include", System, false, false, false);
Rafael Espindolae4b255c2009-10-27 14:47:31 +0000545}
546
Chris Lattner0e3cc052010-05-05 05:28:39 +0000547void InitHeaderSearch::
548AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple) {
Rafael Espindolae4b255c2009-10-27 14:47:31 +0000549 llvm::Triple::OSType os = triple.getOS();
Rafael Espindolaab7ae952009-11-16 19:49:37 +0000550 llvm::StringRef CxxIncludeRoot(CXX_INCLUDE_ROOT);
551 if (CxxIncludeRoot != "") {
552 llvm::StringRef CxxIncludeArch(CXX_INCLUDE_ARCH);
553 if (CxxIncludeArch == "")
554 AddGnuCPlusPlusIncludePaths(CxxIncludeRoot, triple.str().c_str(),
Chris Lattner0e3cc052010-05-05 05:28:39 +0000555 CXX_INCLUDE_32BIT_DIR, CXX_INCLUDE_64BIT_DIR,
556 triple);
Rafael Espindolaab7ae952009-11-16 19:49:37 +0000557 else
558 AddGnuCPlusPlusIncludePaths(CxxIncludeRoot, CXX_INCLUDE_ARCH,
Chris Lattner0e3cc052010-05-05 05:28:39 +0000559 CXX_INCLUDE_32BIT_DIR, CXX_INCLUDE_64BIT_DIR,
560 triple);
Rafael Espindolaab7ae952009-11-16 19:49:37 +0000561 return;
562 }
Rafael Espindolae4b255c2009-10-27 14:47:31 +0000563 // FIXME: temporary hack: hard-coded paths.
564 switch (os) {
565 case llvm::Triple::Cygwin:
NAKAMURA Takumi32df0022010-10-11 02:27:37 +0000566 // Cygwin-1.7
567 AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "4.3.4");
568 // g++-4 / Cygwin-1.5
569 AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "4.3.2");
570 // FIXME: Do we support g++-3.4.4?
571 AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "3.4.4");
Rafael Espindolae4b255c2009-10-27 14:47:31 +0000572 break;
Rafael Espindolae4b255c2009-10-27 14:47:31 +0000573 case llvm::Triple::MinGW32:
NAKAMURA Takumi05c699e2011-02-17 08:51:47 +0000574 // mingw-w64-20110207
Joerg Sonnenberger2df66472011-02-22 00:40:56 +0000575 AddPath("c:/MinGW/include/c++/4.5.3", CXXSystem, true, false, false);
576 AddPath("c:/MinGW/include/c++/4.5.3/x86_64-w64-mingw32", CXXSystem, true,
577 false, false);
578 AddPath("c:/MinGW/include/c++/4.5.3/backward", CXXSystem, true, false,
579 false);
NAKAMURA Takumi05c699e2011-02-17 08:51:47 +0000580 // mingw-w64-20101129
Joerg Sonnenberger2df66472011-02-22 00:40:56 +0000581 AddPath("c:/MinGW/include/c++/4.5.2", CXXSystem, true, false, false);
582 AddPath("c:/MinGW/include/c++/4.5.2/x86_64-w64-mingw32", CXXSystem, true,
583 false, false);
584 AddPath("c:/MinGW/include/c++/4.5.2/backward", CXXSystem, true, false,
585 false);
Douglas Gregorab0d8bd2011-03-06 18:00:59 +0000586 // Try gcc 4.5.2 (MSYS)
587 AddMinGWCPlusPlusIncludePaths("/mingw/lib/gcc", "mingw32", "4.5.2");
NAKAMURA Takumi125b4cb2011-02-17 08:50:50 +0000588 // Try gcc 4.5.0
589 AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", "mingw32", "4.5.0");
Rafael Espindolae4b255c2009-10-27 14:47:31 +0000590 // Try gcc 4.4.0
591 AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", "mingw32", "4.4.0");
592 // Try gcc 4.3.0
593 AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", "mingw32", "4.3.0");
594 break;
595 case llvm::Triple::Darwin:
Daniel Dunbarf2070b32010-05-28 01:54:31 +0000596 switch (triple.getArch()) {
597 default: break;
598
NAKAMURA Takumi125b4cb2011-02-17 08:50:50 +0000599 case llvm::Triple::ppc:
Douglas Gregor582c3012010-05-29 01:15:12 +0000600 case llvm::Triple::ppc64:
Douglas Gregor616d4362010-05-29 01:21:11 +0000601 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
NAKAMURA Takumi125b4cb2011-02-17 08:50:50 +0000602 "powerpc-apple-darwin10", "", "ppc64",
Douglas Gregor616d4362010-05-29 01:21:11 +0000603 triple);
Douglas Gregor582c3012010-05-29 01:15:12 +0000604 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.0.0",
NAKAMURA Takumi125b4cb2011-02-17 08:50:50 +0000605 "powerpc-apple-darwin10", "", "ppc64",
Douglas Gregor582c3012010-05-29 01:15:12 +0000606 triple);
607 break;
608
Daniel Dunbarf2070b32010-05-28 01:54:31 +0000609 case llvm::Triple::x86:
610 case llvm::Triple::x86_64:
611 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
612 "i686-apple-darwin10", "", "x86_64", triple);
613 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.0.0",
614 "i686-apple-darwin8", "", "", triple);
615 break;
616
617 case llvm::Triple::arm:
618 case llvm::Triple::thumb:
619 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
620 "arm-apple-darwin10", "v7", "", triple);
621 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
622 "arm-apple-darwin10", "v6", "", triple);
623 break;
624 }
Rafael Espindolae4b255c2009-10-27 14:47:31 +0000625 break;
Chris Lattner7a7ca282010-01-09 05:41:14 +0000626 case llvm::Triple::DragonFly:
Joerg Sonnenberger2df66472011-02-22 00:40:56 +0000627 AddPath("/usr/include/c++/4.1", CXXSystem, true, false, false);
Chris Lattner7a7ca282010-01-09 05:41:14 +0000628 break;
Rafael Espindolae4b255c2009-10-27 14:47:31 +0000629 case llvm::Triple::Linux:
mike-mac78b7a2010-05-06 14:11:13 +0000630 //===------------------------------------------------------------------===//
631 // Debian based distros.
632 // Note: these distros symlink /usr/include/c++/X.Y.Z -> X.Y
633 //===------------------------------------------------------------------===//
Rafael Espindolac12bbe52011-02-15 21:44:06 +0000634 // Ubuntu 10.10 "Maverick Meerkat" -- gcc-4.4.5
Rafael Espindolaadafdba2011-02-15 21:16:43 +0000635 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4",
636 "i686-linux-gnu", "", "64", triple);
637 // The rest of 10.10 is the same as previous versions.
638
mike-mac78b7a2010-05-06 14:11:13 +0000639 // Ubuntu 10.04 LTS "Lucid Lynx" -- gcc-4.4.3
640 // Ubuntu 9.10 "Karmic Koala" -- gcc-4.4.1
641 // Debian 6.0 "squeeze" -- gcc-4.4.2
642 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4",
643 "x86_64-linux-gnu", "32", "", triple);
644 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4",
645 "i486-linux-gnu", "", "64", triple);
Nick Lewyckydb083552011-02-01 21:32:14 +0000646 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4",
647 "arm-linux-gnueabi", "", "", triple);
mike-mac78b7a2010-05-06 14:11:13 +0000648 // Ubuntu 9.04 "Jaunty Jackalope" -- gcc-4.3.3
649 // Ubuntu 8.10 "Intrepid Ibex" -- gcc-4.3.2
650 // Debian 5.0 "lenny" -- gcc-4.3.2
651 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3",
652 "x86_64-linux-gnu", "32", "", triple);
653 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3",
654 "i486-linux-gnu", "", "64", triple);
Rafael Espindolae7d6c2c2010-06-04 14:28:10 +0000655 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3",
656 "arm-linux-gnueabi", "", "", triple);
mike-mac78b7a2010-05-06 14:11:13 +0000657 // Ubuntu 8.04.4 LTS "Hardy Heron" -- gcc-4.2.4
658 // Ubuntu 8.04.[0-3] LTS "Hardy Heron" -- gcc-4.2.3
659 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2",
660 "x86_64-linux-gnu", "32", "", triple);
661 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2",
662 "i486-linux-gnu", "", "64", triple);
663 // Ubuntu 7.10 "Gutsy Gibbon" -- gcc-4.1.3
664 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1",
665 "x86_64-linux-gnu", "32", "", triple);
666 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1",
667 "i486-linux-gnu", "", "64", triple);
668
669 //===------------------------------------------------------------------===//
670 // Redhat based distros.
671 //===------------------------------------------------------------------===//
Rafael Espindola6638b3a2010-11-02 18:39:34 +0000672 // Fedora 14
673 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5.1",
674 "x86_64-redhat-linux", "32", "", triple);
675 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5.1",
676 "i686-redhat-linux", "", "", triple);
mike-mac78b7a2010-05-06 14:11:13 +0000677 // Fedora 13
Chris Lattner4336e192010-05-29 01:01:38 +0000678 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.4",
679 "x86_64-redhat-linux", "32", "", triple);
680 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.4",
681 "i686-redhat-linux","", "", triple);
mike-mac78b7a2010-05-06 14:11:13 +0000682 // Fedora 12
683 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.3",
684 "x86_64-redhat-linux", "32", "", triple);
685 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.3",
686 "i686-redhat-linux","", "", triple);
687 // Fedora 12 (pre-FEB-2010)
688 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.2",
689 "x86_64-redhat-linux", "32", "", triple);
690 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.2",
691 "i686-redhat-linux","", "", triple);
692 // Fedora 11
693 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.1",
694 "x86_64-redhat-linux", "32", "", triple);
695 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.1",
696 "i586-redhat-linux","", "", triple);
697 // Fedora 10
698 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.2",
699 "x86_64-redhat-linux", "32", "", triple);
700 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.2",
701 "i386-redhat-linux","", "", triple);
702 // Fedora 9
703 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.0",
704 "x86_64-redhat-linux", "32", "", triple);
705 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.0",
706 "i386-redhat-linux", "", "", triple);
707 // Fedora 8
708 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1.2",
709 "x86_64-redhat-linux", "", "", triple);
710 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1.2",
711 "i386-redhat-linux", "", "", triple);
712
713 //===------------------------------------------------------------------===//
714
Benjamin Kramer0db3d722010-01-25 12:20:15 +0000715 // Exherbo (2010-01-25)
716 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.3",
Torok Edwinfc4b8992009-12-18 17:29:14 +0000717 "x86_64-pc-linux-gnu", "32", "", triple);
Benjamin Kramer0db3d722010-01-25 12:20:15 +0000718 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.3",
Torok Edwinfc4b8992009-12-18 17:29:14 +0000719 "i686-pc-linux-gnu", "", "", triple);
Chris Lattnerea00f842010-04-23 15:55:20 +0000720
Rafael Espindolae4b255c2009-10-27 14:47:31 +0000721 // openSUSE 11.1 32 bit
722 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3",
Rafael Espindolaab7ae952009-11-16 19:49:37 +0000723 "i586-suse-linux", "", "", triple);
Rafael Espindolae4b255c2009-10-27 14:47:31 +0000724 // openSUSE 11.1 64 bit
725 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3",
Rafael Espindolaab7ae952009-11-16 19:49:37 +0000726 "x86_64-suse-linux", "32", "", triple);
Rafael Espindolae4b255c2009-10-27 14:47:31 +0000727 // openSUSE 11.2
728 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4",
Rafael Espindolaab7ae952009-11-16 19:49:37 +0000729 "i586-suse-linux", "", "", triple);
Rafael Espindolae4b255c2009-10-27 14:47:31 +0000730 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4",
Rafael Espindolaab7ae952009-11-16 19:49:37 +0000731 "x86_64-suse-linux", "", "", triple);
Rafael Espindola9d2c0602010-11-25 18:51:59 +0000732
733 // openSUSE 11.4
734 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5",
735 "i586-suse-linux", "", "", triple);
736 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5",
737 "x86_64-suse-linux", "", "", triple);
738
Rafael Espindolae4b255c2009-10-27 14:47:31 +0000739 // Arch Linux 2008-06-24
740 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.1",
Rafael Espindolaab7ae952009-11-16 19:49:37 +0000741 "i686-pc-linux-gnu", "", "", triple);
Rafael Espindolae4b255c2009-10-27 14:47:31 +0000742 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.1",
Rafael Espindolaab7ae952009-11-16 19:49:37 +0000743 "x86_64-unknown-linux-gnu", "", "", triple);
Douglas Gregor53703832011-03-14 15:33:44 +0000744 // Gentoo x86 gcc 4.5.2
745 AddGnuCPlusPlusIncludePaths(
746 "/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/g++-v4",
747 "i686-pc-linux-gnu", "", "", triple);
748 // Gentoo x86 gcc 4.4.5
749 AddGnuCPlusPlusIncludePaths(
750 "/usr/lib/gcc/i686-pc-linux-gnu/4.4.5/include/g++-v4",
751 "i686-pc-linux-gnu", "", "", triple);
752 // Gentoo x86 gcc 4.4.4
753 AddGnuCPlusPlusIncludePaths(
754 "/usr/lib/gcc/i686-pc-linux-gnu/4.4.4/include/g++-v4",
755 "i686-pc-linux-gnu", "", "", triple);
756 // Gentoo x86 2010.0 stable
Nuno Lopes0d155a52010-09-11 17:51:45 +0000757 AddGnuCPlusPlusIncludePaths(
758 "/usr/lib/gcc/i686-pc-linux-gnu/4.4.3/include/g++-v4",
759 "i686-pc-linux-gnu", "", "", triple);
Rafael Espindolae4b255c2009-10-27 14:47:31 +0000760 // Gentoo x86 2009.1 stable
761 AddGnuCPlusPlusIncludePaths(
John Thompson40d1bb62009-11-05 22:03:02 +0000762 "/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4",
Rafael Espindolaab7ae952009-11-16 19:49:37 +0000763 "i686-pc-linux-gnu", "", "", triple);
Rafael Espindolae4b255c2009-10-27 14:47:31 +0000764 // Gentoo x86 2009.0 stable
765 AddGnuCPlusPlusIncludePaths(
John Thompson40d1bb62009-11-05 22:03:02 +0000766 "/usr/lib/gcc/i686-pc-linux-gnu/4.3.2/include/g++-v4",
Rafael Espindolaab7ae952009-11-16 19:49:37 +0000767 "i686-pc-linux-gnu", "", "", triple);
Rafael Espindolae4b255c2009-10-27 14:47:31 +0000768 // Gentoo x86 2008.0 stable
769 AddGnuCPlusPlusIncludePaths(
John Thompson40d1bb62009-11-05 22:03:02 +0000770 "/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4",
Rafael Espindolaab7ae952009-11-16 19:49:37 +0000771 "i686-pc-linux-gnu", "", "", triple);
Douglas Gregor53703832011-03-14 15:33:44 +0000772 // Gentoo x86 llvm-gcc trunk
773 AddGnuCPlusPlusIncludePaths(
774 "/usr/lib/llvm-gcc-4.2-9999/include/c++/4.2.1",
775 "i686-pc-linux-gnu", "", "", triple);
Nick Lewycky66935342010-07-24 21:33:13 +0000776
Douglas Gregor53703832011-03-14 15:33:44 +0000777 // Gentoo amd64 gcc 4.5.2
778 AddGnuCPlusPlusIncludePaths(
779 "/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/include/g++-v4",
780 "x86_64-pc-linux-gnu", "32", "", triple);
Chandler Carruthfbfdb202010-11-28 07:20:14 +0000781 // Gentoo amd64 gcc 4.4.5
782 AddGnuCPlusPlusIncludePaths(
783 "/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.5/include/g++-v4",
784 "x86_64-pc-linux-gnu", "32", "", triple);
Nico Weber8ad8a1c2010-11-16 12:42:55 +0000785 // Gentoo amd64 gcc 4.4.4
786 AddGnuCPlusPlusIncludePaths(
787 "/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.4/include/g++-v4",
788 "x86_64-pc-linux-gnu", "32", "", triple);
Chandler Carruthfbfdb202010-11-28 07:20:14 +0000789 // Gentoo amd64 gcc 4.4.3
790 AddGnuCPlusPlusIncludePaths(
791 "/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.3/include/g++-v4",
792 "x86_64-pc-linux-gnu", "32", "", triple);
793 // Gentoo amd64 gcc 4.3.2
794 AddGnuCPlusPlusIncludePaths(
795 "/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/include/g++-v4",
796 "x86_64-pc-linux-gnu", "", "", triple);
797 // Gentoo amd64 stable
798 AddGnuCPlusPlusIncludePaths(
799 "/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/include/g++-v4",
Douglas Gregor53703832011-03-14 15:33:44 +0000800 "x86_64-pc-linux-gnu", "", "", triple);
Nico Weber8ad8a1c2010-11-16 12:42:55 +0000801
Nick Lewycky66935342010-07-24 21:33:13 +0000802 // Gentoo amd64 llvm-gcc trunk
803 AddGnuCPlusPlusIncludePaths(
804 "/usr/lib/llvm-gcc-4.2-9999/include/c++/4.2.1",
805 "x86_64-pc-linux-gnu", "", "", triple);
Chandler Carruthfbfdb202010-11-28 07:20:14 +0000806
Rafael Espindolae4b255c2009-10-27 14:47:31 +0000807 break;
808 case llvm::Triple::FreeBSD:
mike-mac78b7a2010-05-06 14:11:13 +0000809 // FreeBSD 8.0
810 // FreeBSD 7.3
Nuno Lopesafe859a2010-01-17 00:00:11 +0000811 AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2", "", "", "", triple);
Rafael Espindolae4b255c2009-10-27 14:47:31 +0000812 break;
Anton Korobeynikovab079412010-08-31 22:39:50 +0000813 case llvm::Triple::NetBSD:
814 AddGnuCPlusPlusIncludePaths("/usr/include/g++", "", "", "", triple);
815 break;
Daniel Dunbar95c04572010-08-01 23:13:54 +0000816 case llvm::Triple::OpenBSD: {
817 std::string t = triple.getTriple();
818 if (t.substr(0, 6) == "x86_64")
819 t.replace(0, 6, "amd64");
820 AddGnuCPlusPlusIncludePaths("/usr/include/g++",
821 t, "", "", triple);
822 break;
823 }
Chris Lattner38e317d2010-07-07 16:01:42 +0000824 case llvm::Triple::Minix:
825 AddGnuCPlusPlusIncludePaths("/usr/gnu/include/c++/4.4.3",
826 "", "", "", triple);
827 break;
Rafael Espindolae4b255c2009-10-27 14:47:31 +0000828 case llvm::Triple::Solaris:
829 // Solaris - Fall though..
830 case llvm::Triple::AuroraUX:
831 // AuroraUX
832 AddGnuCPlusPlusIncludePaths("/opt/gcc4/include/c++/4.2.4",
Rafael Espindolaab7ae952009-11-16 19:49:37 +0000833 "i386-pc-solaris2.11", "", "", triple);
Rafael Espindolae4b255c2009-10-27 14:47:31 +0000834 break;
835 default:
836 break;
837 }
838}
839
Rafael Espindolae4b255c2009-10-27 14:47:31 +0000840void InitHeaderSearch::AddDefaultSystemIncludePaths(const LangOptions &Lang,
Douglas Gregor4c2bcad2010-03-24 20:13:48 +0000841 const llvm::Triple &triple,
mike-m79bc57c2010-05-16 19:03:52 +0000842 const HeaderSearchOptions &HSOpts) {
Joerg Sonnenberger0bb208c2011-02-22 15:19:35 +0000843 if (Lang.CPlusPlus && HSOpts.UseStandardCXXIncludes)
844 AddDefaultCPlusPlusIncludePaths(triple);
Rafael Espindola6ec18a32009-11-23 16:31:19 +0000845
mike-m79bc57c2010-05-16 19:03:52 +0000846 AddDefaultCIncludePaths(triple, HSOpts);
Daniel Dunbare1665822009-11-07 04:20:39 +0000847
848 // Add the default framework include paths on Darwin.
849 if (triple.getOS() == llvm::Triple::Darwin) {
850 AddPath("/System/Library/Frameworks", System, true, false, true);
851 AddPath("/Library/Frameworks", System, true, false, true);
852 }
Rafael Espindolae4b255c2009-10-27 14:47:31 +0000853}
854
Nico Weber0fca0222008-08-22 09:25:22 +0000855/// RemoveDuplicates - If there are duplicate directory entries in the specified
856/// search list, remove the later (dead) ones.
857static void RemoveDuplicates(std::vector<DirectoryLookup> &SearchList,
Joerg Sonnenberger2df66472011-02-22 00:40:56 +0000858 unsigned First, bool Verbose) {
Nico Weber0fca0222008-08-22 09:25:22 +0000859 llvm::SmallPtrSet<const DirectoryEntry *, 8> SeenDirs;
860 llvm::SmallPtrSet<const DirectoryEntry *, 8> SeenFrameworkDirs;
861 llvm::SmallPtrSet<const HeaderMap *, 8> SeenHeaderMaps;
Joerg Sonnenberger2df66472011-02-22 00:40:56 +0000862 for (unsigned i = First; i != SearchList.size(); ++i) {
Chris Lattner7a739402008-09-26 17:46:45 +0000863 unsigned DirToRemove = i;
Mike Stump1eb44332009-09-09 15:08:12 +0000864
Chris Lattner43eee072009-02-08 01:00:10 +0000865 const DirectoryLookup &CurEntry = SearchList[i];
Mike Stump1eb44332009-09-09 15:08:12 +0000866
Chris Lattner43eee072009-02-08 01:00:10 +0000867 if (CurEntry.isNormalDir()) {
Nico Weber0fca0222008-08-22 09:25:22 +0000868 // If this isn't the first time we've seen this dir, remove it.
Chris Lattner43eee072009-02-08 01:00:10 +0000869 if (SeenDirs.insert(CurEntry.getDir()))
Nico Weber0fca0222008-08-22 09:25:22 +0000870 continue;
Chris Lattner43eee072009-02-08 01:00:10 +0000871 } else if (CurEntry.isFramework()) {
Nico Weber0fca0222008-08-22 09:25:22 +0000872 // If this isn't the first time we've seen this framework dir, remove it.
Chris Lattner43eee072009-02-08 01:00:10 +0000873 if (SeenFrameworkDirs.insert(CurEntry.getFrameworkDir()))
Nico Weber0fca0222008-08-22 09:25:22 +0000874 continue;
Nico Weber0fca0222008-08-22 09:25:22 +0000875 } else {
Chris Lattner43eee072009-02-08 01:00:10 +0000876 assert(CurEntry.isHeaderMap() && "Not a headermap or normal dir?");
Nico Weber0fca0222008-08-22 09:25:22 +0000877 // If this isn't the first time we've seen this headermap, remove it.
Chris Lattner43eee072009-02-08 01:00:10 +0000878 if (SeenHeaderMaps.insert(CurEntry.getHeaderMap()))
Nico Weber0fca0222008-08-22 09:25:22 +0000879 continue;
Chris Lattner30f05b52009-02-08 00:55:22 +0000880 }
Mike Stump1eb44332009-09-09 15:08:12 +0000881
Chris Lattner30f05b52009-02-08 00:55:22 +0000882 // If we have a normal #include dir/framework/headermap that is shadowed
883 // later in the chain by a system include location, we actually want to
884 // ignore the user's request and drop the user dir... keeping the system
885 // dir. This is weird, but required to emulate GCC's search path correctly.
886 //
887 // Since dupes of system dirs are rare, just rescan to find the original
888 // that we're nuking instead of using a DenseMap.
Chris Lattner43eee072009-02-08 01:00:10 +0000889 if (CurEntry.getDirCharacteristic() != SrcMgr::C_User) {
Chris Lattner30f05b52009-02-08 00:55:22 +0000890 // Find the dir that this is the same of.
891 unsigned FirstDir;
892 for (FirstDir = 0; ; ++FirstDir) {
893 assert(FirstDir != i && "Didn't find dupe?");
Mike Stump1eb44332009-09-09 15:08:12 +0000894
Chris Lattner43eee072009-02-08 01:00:10 +0000895 const DirectoryLookup &SearchEntry = SearchList[FirstDir];
896
Chris Lattner30f05b52009-02-08 00:55:22 +0000897 // If these are different lookup types, then they can't be the dupe.
Chris Lattner43eee072009-02-08 01:00:10 +0000898 if (SearchEntry.getLookupType() != CurEntry.getLookupType())
Chris Lattner30f05b52009-02-08 00:55:22 +0000899 continue;
Mike Stump1eb44332009-09-09 15:08:12 +0000900
Chris Lattner30f05b52009-02-08 00:55:22 +0000901 bool isSame;
Chris Lattner43eee072009-02-08 01:00:10 +0000902 if (CurEntry.isNormalDir())
903 isSame = SearchEntry.getDir() == CurEntry.getDir();
904 else if (CurEntry.isFramework())
905 isSame = SearchEntry.getFrameworkDir() == CurEntry.getFrameworkDir();
Chris Lattner30f05b52009-02-08 00:55:22 +0000906 else {
Chris Lattner43eee072009-02-08 01:00:10 +0000907 assert(CurEntry.isHeaderMap() && "Not a headermap or normal dir?");
908 isSame = SearchEntry.getHeaderMap() == CurEntry.getHeaderMap();
Chris Lattner30f05b52009-02-08 00:55:22 +0000909 }
Mike Stump1eb44332009-09-09 15:08:12 +0000910
Chris Lattner30f05b52009-02-08 00:55:22 +0000911 if (isSame)
912 break;
913 }
Mike Stump1eb44332009-09-09 15:08:12 +0000914
Chris Lattner30f05b52009-02-08 00:55:22 +0000915 // If the first dir in the search path is a non-system dir, zap it
916 // instead of the system one.
917 if (SearchList[FirstDir].getDirCharacteristic() == SrcMgr::C_User)
918 DirToRemove = FirstDir;
919 }
920
921 if (Verbose) {
Daniel Dunbare7cb7e42009-12-03 09:14:02 +0000922 llvm::errs() << "ignoring duplicate directory \""
923 << CurEntry.getName() << "\"\n";
Chris Lattner30f05b52009-02-08 00:55:22 +0000924 if (DirToRemove != i)
Daniel Dunbare7cb7e42009-12-03 09:14:02 +0000925 llvm::errs() << " as it is a non-system directory that duplicates "
926 << "a system directory\n";
Nico Weber0fca0222008-08-22 09:25:22 +0000927 }
Mike Stump1eb44332009-09-09 15:08:12 +0000928
Chris Lattner7a739402008-09-26 17:46:45 +0000929 // This is reached if the current entry is a duplicate. Remove the
930 // DirToRemove (usually the current dir).
931 SearchList.erase(SearchList.begin()+DirToRemove);
Nico Weber0fca0222008-08-22 09:25:22 +0000932 --i;
933 }
934}
935
936
Joerg Sonnenberger2df66472011-02-22 00:40:56 +0000937void InitHeaderSearch::Realize(const LangOptions &Lang) {
Nico Weber0fca0222008-08-22 09:25:22 +0000938 // Concatenate ANGLE+SYSTEM+AFTER chains together into SearchList.
939 std::vector<DirectoryLookup> SearchList;
Joerg Sonnenberger2df66472011-02-22 00:40:56 +0000940 SearchList.reserve(IncludePath.size());
Mike Stump1eb44332009-09-09 15:08:12 +0000941
Joerg Sonnenberger2df66472011-02-22 00:40:56 +0000942 /* Quoted arguments go first. */
943 for (path_iterator it = IncludePath.begin(), ie = IncludePath.end();
944 it != ie; ++it) {
945 if (it->first == Quoted)
946 SearchList.push_back(it->second);
947 }
948 /* Deduplicate and remember index */
949 RemoveDuplicates(SearchList, 0, Verbose);
950 unsigned quoted = SearchList.size();
Mike Stump1eb44332009-09-09 15:08:12 +0000951
Joerg Sonnenberger2df66472011-02-22 00:40:56 +0000952 for (path_iterator it = IncludePath.begin(), ie = IncludePath.end();
953 it != ie; ++it) {
954 if (it->first == Angled)
955 SearchList.push_back(it->second);
956 }
957
958 for (path_iterator it = IncludePath.begin(), ie = IncludePath.end();
959 it != ie; ++it) {
960 if (it->first == System || (Lang.CPlusPlus && it->first == CXXSystem))
961 SearchList.push_back(it->second);
962 }
963
964 for (path_iterator it = IncludePath.begin(), ie = IncludePath.end();
965 it != ie; ++it) {
966 if (it->first == After)
967 SearchList.push_back(it->second);
968 }
969
970 RemoveDuplicates(SearchList, quoted, Verbose);
Nico Weber0fca0222008-08-22 09:25:22 +0000971
972 bool DontSearchCurDir = false; // TODO: set to true if -I- is set?
Joerg Sonnenberger2df66472011-02-22 00:40:56 +0000973 Headers.SetSearchPaths(SearchList, quoted, DontSearchCurDir);
Nico Weber0fca0222008-08-22 09:25:22 +0000974
975 // If verbose, print the list of directories that will be searched.
976 if (Verbose) {
Daniel Dunbare7cb7e42009-12-03 09:14:02 +0000977 llvm::errs() << "#include \"...\" search starts here:\n";
Nico Weber0fca0222008-08-22 09:25:22 +0000978 for (unsigned i = 0, e = SearchList.size(); i != e; ++i) {
Joerg Sonnenberger2df66472011-02-22 00:40:56 +0000979 if (i == quoted)
Daniel Dunbare7cb7e42009-12-03 09:14:02 +0000980 llvm::errs() << "#include <...> search starts here:\n";
Nico Weber0fca0222008-08-22 09:25:22 +0000981 const char *Name = SearchList[i].getName();
982 const char *Suffix;
983 if (SearchList[i].isNormalDir())
984 Suffix = "";
985 else if (SearchList[i].isFramework())
986 Suffix = " (framework directory)";
987 else {
988 assert(SearchList[i].isHeaderMap() && "Unknown DirectoryLookup");
989 Suffix = " (headermap)";
990 }
Daniel Dunbare7cb7e42009-12-03 09:14:02 +0000991 llvm::errs() << " " << Name << Suffix << "\n";
Nico Weber0fca0222008-08-22 09:25:22 +0000992 }
Daniel Dunbare7cb7e42009-12-03 09:14:02 +0000993 llvm::errs() << "End of search list.\n";
Nico Weber0fca0222008-08-22 09:25:22 +0000994 }
995}
Daniel Dunbar63c8b772009-11-07 04:20:50 +0000996
Daniel Dunbar5814e652009-11-11 21:44:21 +0000997void clang::ApplyHeaderSearchOptions(HeaderSearch &HS,
998 const HeaderSearchOptions &HSOpts,
999 const LangOptions &Lang,
Daniel Dunbar63c8b772009-11-07 04:20:50 +00001000 const llvm::Triple &Triple) {
1001 InitHeaderSearch Init(HS, HSOpts.Verbose, HSOpts.Sysroot);
1002
1003 // Add the user defined entries.
1004 for (unsigned i = 0, e = HSOpts.UserEntries.size(); i != e; ++i) {
1005 const HeaderSearchOptions::Entry &E = HSOpts.UserEntries[i];
Daniel Dunbar1b483e72009-11-17 05:04:15 +00001006 Init.AddPath(E.Path, E.Group, false, E.IsUserSupplied, E.IsFramework,
Chris Lattner23637be2010-08-24 22:27:37 +00001007 !E.IsSysRootRelative);
Daniel Dunbar63c8b772009-11-07 04:20:50 +00001008 }
1009
1010 // Add entries from CPATH and friends.
Benjamin Kramer9e9ddf62009-12-08 12:11:06 +00001011 Init.AddDelimitedPaths(HSOpts.EnvIncPath);
Daniel Dunbarc363cb12009-11-16 22:38:40 +00001012 if (Lang.CPlusPlus && Lang.ObjC1)
Benjamin Kramer9e9ddf62009-12-08 12:11:06 +00001013 Init.AddDelimitedPaths(HSOpts.ObjCXXEnvIncPath);
Daniel Dunbarc363cb12009-11-16 22:38:40 +00001014 else if (Lang.CPlusPlus)
Benjamin Kramer9e9ddf62009-12-08 12:11:06 +00001015 Init.AddDelimitedPaths(HSOpts.CXXEnvIncPath);
Daniel Dunbarc363cb12009-11-16 22:38:40 +00001016 else if (Lang.ObjC1)
Benjamin Kramer9e9ddf62009-12-08 12:11:06 +00001017 Init.AddDelimitedPaths(HSOpts.ObjCEnvIncPath);
Daniel Dunbarc363cb12009-11-16 22:38:40 +00001018 else
Benjamin Kramer9e9ddf62009-12-08 12:11:06 +00001019 Init.AddDelimitedPaths(HSOpts.CEnvIncPath);
Daniel Dunbar63c8b772009-11-07 04:20:50 +00001020
Daniel Dunbardd35ce92009-11-07 04:58:12 +00001021 if (HSOpts.UseStandardIncludes)
mike-m79bc57c2010-05-16 19:03:52 +00001022 Init.AddDefaultSystemIncludePaths(Lang, Triple, HSOpts);
Daniel Dunbar63c8b772009-11-07 04:20:50 +00001023
Joerg Sonnenberger2df66472011-02-22 00:40:56 +00001024 Init.Realize(Lang);
Daniel Dunbar63c8b772009-11-07 04:20:50 +00001025}