InitHeaderSearch.cpp 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935
  1. //===--- InitHeaderSearch.cpp - Initialize header search paths ------------===//
  2. //
  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. #ifdef HAVE_CLANG_CONFIG_H
  14. # include "clang/Config/config.h"
  15. #endif
  16. #include "clang/Frontend/Utils.h"
  17. #include "clang/Basic/FileManager.h"
  18. #include "clang/Basic/LangOptions.h"
  19. #include "clang/Frontend/HeaderSearchOptions.h"
  20. #include "clang/Lex/HeaderSearch.h"
  21. #include "llvm/ADT/SmallString.h"
  22. #include "llvm/ADT/SmallPtrSet.h"
  23. #include "llvm/ADT/SmallVector.h"
  24. #include "llvm/ADT/StringExtras.h"
  25. #include "llvm/ADT/Triple.h"
  26. #include "llvm/ADT/Twine.h"
  27. #include "llvm/Support/raw_ostream.h"
  28. #include "llvm/Support/ErrorHandling.h"
  29. #include "llvm/Support/Path.h"
  30. #include "llvm/Config/config.h"
  31. using namespace clang;
  32. using namespace clang::frontend;
  33. namespace {
  34. /// InitHeaderSearch - This class makes it easier to set the search paths of
  35. /// a HeaderSearch object. InitHeaderSearch stores several search path lists
  36. /// internally, which can be sent to a HeaderSearch object in one swoop.
  37. class InitHeaderSearch {
  38. std::vector<std::pair<IncludeDirGroup, DirectoryLookup> > IncludePath;
  39. typedef std::vector<std::pair<IncludeDirGroup,
  40. DirectoryLookup> >::const_iterator path_iterator;
  41. HeaderSearch &Headers;
  42. bool Verbose;
  43. std::string IncludeSysroot;
  44. bool IsNotEmptyOrRoot;
  45. public:
  46. InitHeaderSearch(HeaderSearch &HS, bool verbose, StringRef sysroot)
  47. : Headers(HS), Verbose(verbose), IncludeSysroot(sysroot),
  48. IsNotEmptyOrRoot(!(sysroot.empty() || sysroot == "/")) {
  49. }
  50. /// AddPath - Add the specified path to the specified group list.
  51. void AddPath(const Twine &Path, IncludeDirGroup Group,
  52. bool isCXXAware, bool isUserSupplied,
  53. bool isFramework, bool IgnoreSysRoot = false);
  54. /// AddGnuCPlusPlusIncludePaths - Add the necessary paths to support a gnu
  55. /// libstdc++.
  56. void AddGnuCPlusPlusIncludePaths(StringRef Base,
  57. StringRef ArchDir,
  58. StringRef Dir32,
  59. StringRef Dir64,
  60. const llvm::Triple &triple);
  61. /// AddMinGWCPlusPlusIncludePaths - Add the necessary paths to support a MinGW
  62. /// libstdc++.
  63. void AddMinGWCPlusPlusIncludePaths(StringRef Base,
  64. StringRef Arch,
  65. StringRef Version);
  66. /// AddMinGW64CXXPaths - Add the necessary paths to support
  67. /// libstdc++ of x86_64-w64-mingw32 aka mingw-w64.
  68. void AddMinGW64CXXPaths(StringRef Base,
  69. StringRef Version);
  70. // AddDefaultCIncludePaths - Add paths that should always be searched.
  71. void AddDefaultCIncludePaths(const llvm::Triple &triple,
  72. const HeaderSearchOptions &HSOpts);
  73. // AddDefaultCPlusPlusIncludePaths - Add paths that should be searched when
  74. // compiling c++.
  75. void AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple,
  76. const HeaderSearchOptions &HSOpts);
  77. /// AddDefaultSystemIncludePaths - Adds the default system include paths so
  78. /// that e.g. stdio.h is found.
  79. void AddDefaultIncludePaths(const LangOptions &Lang,
  80. const llvm::Triple &triple,
  81. const HeaderSearchOptions &HSOpts);
  82. /// Realize - Merges all search path lists into one list and send it to
  83. /// HeaderSearch.
  84. void Realize(const LangOptions &Lang);
  85. };
  86. } // end anonymous namespace.
  87. void InitHeaderSearch::AddPath(const Twine &Path,
  88. IncludeDirGroup Group, bool isCXXAware,
  89. bool isUserSupplied, bool isFramework,
  90. bool IgnoreSysRoot) {
  91. assert(!Path.isTriviallyEmpty() && "can't handle empty path here");
  92. FileManager &FM = Headers.getFileMgr();
  93. // Compute the actual path, taking into consideration -isysroot.
  94. llvm::SmallString<256> MappedPathStorage;
  95. StringRef MappedPathStr = Path.toStringRef(MappedPathStorage);
  96. // Handle isysroot.
  97. if ((Group == System || Group == CXXSystem) && !IgnoreSysRoot &&
  98. #if defined(_WIN32)
  99. !MappedPathStr.empty() &&
  100. llvm::sys::path::is_separator(MappedPathStr[0]) &&
  101. #else
  102. llvm::sys::path::is_absolute(MappedPathStr) &&
  103. #endif
  104. IsNotEmptyOrRoot) {
  105. MappedPathStorage.clear();
  106. MappedPathStr =
  107. (IncludeSysroot + Path).toStringRef(MappedPathStorage);
  108. }
  109. // Compute the DirectoryLookup type.
  110. SrcMgr::CharacteristicKind Type;
  111. if (Group == Quoted || Group == Angled || Group == IndexHeaderMap)
  112. Type = SrcMgr::C_User;
  113. else if (isCXXAware)
  114. Type = SrcMgr::C_System;
  115. else
  116. Type = SrcMgr::C_ExternCSystem;
  117. // If the directory exists, add it.
  118. if (const DirectoryEntry *DE = FM.getDirectory(MappedPathStr)) {
  119. IncludePath.push_back(std::make_pair(Group, DirectoryLookup(DE, Type,
  120. isUserSupplied, isFramework)));
  121. return;
  122. }
  123. // Check to see if this is an apple-style headermap (which are not allowed to
  124. // be frameworks).
  125. if (!isFramework) {
  126. if (const FileEntry *FE = FM.getFile(MappedPathStr)) {
  127. if (const HeaderMap *HM = Headers.CreateHeaderMap(FE)) {
  128. // It is a headermap, add it to the search path.
  129. IncludePath.push_back(std::make_pair(Group, DirectoryLookup(HM, Type,
  130. isUserSupplied, Group == IndexHeaderMap)));
  131. return;
  132. }
  133. }
  134. }
  135. if (Verbose)
  136. llvm::errs() << "ignoring nonexistent directory \""
  137. << MappedPathStr << "\"\n";
  138. }
  139. void InitHeaderSearch::AddGnuCPlusPlusIncludePaths(StringRef Base,
  140. StringRef ArchDir,
  141. StringRef Dir32,
  142. StringRef Dir64,
  143. const llvm::Triple &triple) {
  144. // Add the base dir
  145. AddPath(Base, CXXSystem, true, false, false);
  146. // Add the multilib dirs
  147. llvm::Triple::ArchType arch = triple.getArch();
  148. bool is64bit = arch == llvm::Triple::ppc64 || arch == llvm::Triple::x86_64;
  149. if (is64bit)
  150. AddPath(Base + "/" + ArchDir + "/" + Dir64, CXXSystem, true, false, false);
  151. else
  152. AddPath(Base + "/" + ArchDir + "/" + Dir32, CXXSystem, true, false, false);
  153. // Add the backward dir
  154. AddPath(Base + "/backward", CXXSystem, true, false, false);
  155. }
  156. void InitHeaderSearch::AddMinGWCPlusPlusIncludePaths(StringRef Base,
  157. StringRef Arch,
  158. StringRef Version) {
  159. AddPath(Base + "/" + Arch + "/" + Version + "/include/c++",
  160. CXXSystem, true, false, false);
  161. AddPath(Base + "/" + Arch + "/" + Version + "/include/c++/" + Arch,
  162. CXXSystem, true, false, false);
  163. AddPath(Base + "/" + Arch + "/" + Version + "/include/c++/backward",
  164. CXXSystem, true, false, false);
  165. }
  166. void InitHeaderSearch::AddMinGW64CXXPaths(StringRef Base,
  167. StringRef Version) {
  168. // Assumes Base is HeaderSearchOpts' ResourceDir
  169. AddPath(Base + "/../../../include/c++/" + Version,
  170. CXXSystem, true, false, false);
  171. AddPath(Base + "/../../../include/c++/" + Version + "/x86_64-w64-mingw32",
  172. CXXSystem, true, false, false);
  173. AddPath(Base + "/../../../include/c++/" + Version + "/i686-w64-mingw32",
  174. CXXSystem, true, false, false);
  175. AddPath(Base + "/../../../include/c++/" + Version + "/backward",
  176. CXXSystem, true, false, false);
  177. }
  178. void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
  179. const HeaderSearchOptions &HSOpts) {
  180. llvm::Triple::OSType os = triple.getOS();
  181. if (HSOpts.UseStandardSystemIncludes) {
  182. switch (os) {
  183. case llvm::Triple::FreeBSD:
  184. case llvm::Triple::NetBSD:
  185. break;
  186. default:
  187. // FIXME: temporary hack: hard-coded paths.
  188. AddPath("/usr/local/include", System, true, false, false);
  189. break;
  190. }
  191. }
  192. // Builtin includes use #include_next directives and should be positioned
  193. // just prior C include dirs.
  194. if (HSOpts.UseBuiltinIncludes) {
  195. // Ignore the sys root, we *always* look for clang headers relative to
  196. // supplied path.
  197. llvm::sys::Path P(HSOpts.ResourceDir);
  198. P.appendComponent("include");
  199. AddPath(P.str(), System, false, false, false, /*IgnoreSysRoot=*/ true);
  200. }
  201. // All remaining additions are for system include directories, early exit if
  202. // we aren't using them.
  203. if (!HSOpts.UseStandardSystemIncludes)
  204. return;
  205. // Add dirs specified via 'configure --with-c-include-dirs'.
  206. StringRef CIncludeDirs(C_INCLUDE_DIRS);
  207. if (CIncludeDirs != "") {
  208. SmallVector<StringRef, 5> dirs;
  209. CIncludeDirs.split(dirs, ":");
  210. for (SmallVectorImpl<StringRef>::iterator i = dirs.begin();
  211. i != dirs.end();
  212. ++i)
  213. AddPath(*i, System, false, false, false);
  214. return;
  215. }
  216. switch (os) {
  217. case llvm::Triple::Win32:
  218. llvm_unreachable("Windows include management is handled in the driver.");
  219. case llvm::Triple::Haiku:
  220. AddPath("/boot/common/include", System, true, false, false);
  221. AddPath("/boot/develop/headers/os", System, true, false, false);
  222. AddPath("/boot/develop/headers/os/app", System, true, false, false);
  223. AddPath("/boot/develop/headers/os/arch", System, true, false, false);
  224. AddPath("/boot/develop/headers/os/device", System, true, false, false);
  225. AddPath("/boot/develop/headers/os/drivers", System, true, false, false);
  226. AddPath("/boot/develop/headers/os/game", System, true, false, false);
  227. AddPath("/boot/develop/headers/os/interface", System, true, false, false);
  228. AddPath("/boot/develop/headers/os/kernel", System, true, false, false);
  229. AddPath("/boot/develop/headers/os/locale", System, true, false, false);
  230. AddPath("/boot/develop/headers/os/mail", System, true, false, false);
  231. AddPath("/boot/develop/headers/os/media", System, true, false, false);
  232. AddPath("/boot/develop/headers/os/midi", System, true, false, false);
  233. AddPath("/boot/develop/headers/os/midi2", System, true, false, false);
  234. AddPath("/boot/develop/headers/os/net", System, true, false, false);
  235. AddPath("/boot/develop/headers/os/storage", System, true, false, false);
  236. AddPath("/boot/develop/headers/os/support", System, true, false, false);
  237. AddPath("/boot/develop/headers/os/translation",
  238. System, true, false, false);
  239. AddPath("/boot/develop/headers/os/add-ons/graphics",
  240. System, true, false, false);
  241. AddPath("/boot/develop/headers/os/add-ons/input_server",
  242. System, true, false, false);
  243. AddPath("/boot/develop/headers/os/add-ons/screen_saver",
  244. System, true, false, false);
  245. AddPath("/boot/develop/headers/os/add-ons/tracker",
  246. System, true, false, false);
  247. AddPath("/boot/develop/headers/os/be_apps/Deskbar",
  248. System, true, false, false);
  249. AddPath("/boot/develop/headers/os/be_apps/NetPositive",
  250. System, true, false, false);
  251. AddPath("/boot/develop/headers/os/be_apps/Tracker",
  252. System, true, false, false);
  253. AddPath("/boot/develop/headers/cpp", System, true, false, false);
  254. AddPath("/boot/develop/headers/cpp/i586-pc-haiku",
  255. System, true, false, false);
  256. AddPath("/boot/develop/headers/3rdparty", System, true, false, false);
  257. AddPath("/boot/develop/headers/bsd", System, true, false, false);
  258. AddPath("/boot/develop/headers/glibc", System, true, false, false);
  259. AddPath("/boot/develop/headers/posix", System, true, false, false);
  260. AddPath("/boot/develop/headers", System, true, false, false);
  261. break;
  262. case llvm::Triple::RTEMS:
  263. break;
  264. case llvm::Triple::Cygwin:
  265. AddPath("/usr/include/w32api", System, true, false, false);
  266. break;
  267. case llvm::Triple::MinGW32: {
  268. // mingw-w64 crt include paths
  269. llvm::sys::Path P(HSOpts.ResourceDir);
  270. P.appendComponent("../../../i686-w64-mingw32/include"); // <sysroot>/i686-w64-mingw32/include
  271. AddPath(P.str(), System, true, false, false);
  272. P = llvm::sys::Path(HSOpts.ResourceDir);
  273. P.appendComponent("../../../x86_64-w64-mingw32/include"); // <sysroot>/x86_64-w64-mingw32/include
  274. AddPath(P.str(), System, true, false, false);
  275. // mingw.org crt include paths
  276. P = llvm::sys::Path(HSOpts.ResourceDir);
  277. P.appendComponent("../../../include"); // <sysroot>/include
  278. AddPath(P.str(), System, true, false, false);
  279. AddPath("/mingw/include", System, true, false, false);
  280. AddPath("c:/mingw/include", System, true, false, false);
  281. }
  282. break;
  283. case llvm::Triple::Linux:
  284. // Generic Debian multiarch support:
  285. if (triple.getArch() == llvm::Triple::x86_64) {
  286. AddPath("/usr/include/x86_64-linux-gnu", System, false, false, false);
  287. AddPath("/usr/include/i686-linux-gnu/64", System, false, false, false);
  288. AddPath("/usr/include/i486-linux-gnu/64", System, false, false, false);
  289. } else if (triple.getArch() == llvm::Triple::x86) {
  290. AddPath("/usr/include/x86_64-linux-gnu/32", System, false, false, false);
  291. AddPath("/usr/include/i686-linux-gnu", System, false, false, false);
  292. AddPath("/usr/include/i486-linux-gnu", System, false, false, false);
  293. AddPath("/usr/include/i386-linux-gnu", System, false, false, false);
  294. } else if (triple.getArch() == llvm::Triple::arm) {
  295. AddPath("/usr/include/arm-linux-gnueabi", System, false, false, false);
  296. }
  297. default:
  298. break;
  299. }
  300. if ( os != llvm::Triple::RTEMS )
  301. AddPath("/usr/include", System, false, false, false);
  302. }
  303. void InitHeaderSearch::
  304. AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple, const HeaderSearchOptions &HSOpts) {
  305. llvm::Triple::OSType os = triple.getOS();
  306. StringRef CxxIncludeRoot(CXX_INCLUDE_ROOT);
  307. if (CxxIncludeRoot != "") {
  308. StringRef CxxIncludeArch(CXX_INCLUDE_ARCH);
  309. if (CxxIncludeArch == "")
  310. AddGnuCPlusPlusIncludePaths(CxxIncludeRoot, triple.str().c_str(),
  311. CXX_INCLUDE_32BIT_DIR, CXX_INCLUDE_64BIT_DIR,
  312. triple);
  313. else
  314. AddGnuCPlusPlusIncludePaths(CxxIncludeRoot, CXX_INCLUDE_ARCH,
  315. CXX_INCLUDE_32BIT_DIR, CXX_INCLUDE_64BIT_DIR,
  316. triple);
  317. return;
  318. }
  319. // FIXME: temporary hack: hard-coded paths.
  320. if (triple.isOSDarwin()) {
  321. switch (triple.getArch()) {
  322. default: break;
  323. case llvm::Triple::ppc:
  324. case llvm::Triple::ppc64:
  325. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
  326. "powerpc-apple-darwin10", "", "ppc64",
  327. triple);
  328. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.0.0",
  329. "powerpc-apple-darwin10", "", "ppc64",
  330. triple);
  331. break;
  332. case llvm::Triple::x86:
  333. case llvm::Triple::x86_64:
  334. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
  335. "i686-apple-darwin10", "", "x86_64", triple);
  336. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.0.0",
  337. "i686-apple-darwin8", "", "", triple);
  338. break;
  339. case llvm::Triple::arm:
  340. case llvm::Triple::thumb:
  341. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
  342. "arm-apple-darwin10", "v7", "", triple);
  343. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
  344. "arm-apple-darwin10", "v6", "", triple);
  345. break;
  346. }
  347. return;
  348. }
  349. switch (os) {
  350. case llvm::Triple::Cygwin:
  351. // Cygwin-1.7
  352. AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "4.3.4");
  353. // g++-4 / Cygwin-1.5
  354. AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "4.3.2");
  355. // FIXME: Do we support g++-3.4.4?
  356. AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "3.4.4");
  357. break;
  358. case llvm::Triple::MinGW32:
  359. // mingw-w64 C++ include paths (i686-w64-mingw32 and x86_64-w64-mingw32)
  360. AddMinGW64CXXPaths(HSOpts.ResourceDir, "4.5.0");
  361. AddMinGW64CXXPaths(HSOpts.ResourceDir, "4.5.1");
  362. AddMinGW64CXXPaths(HSOpts.ResourceDir, "4.5.2");
  363. AddMinGW64CXXPaths(HSOpts.ResourceDir, "4.5.3");
  364. AddMinGW64CXXPaths(HSOpts.ResourceDir, "4.6.0");
  365. AddMinGW64CXXPaths(HSOpts.ResourceDir, "4.6.1");
  366. AddMinGW64CXXPaths(HSOpts.ResourceDir, "4.6.2");
  367. AddMinGW64CXXPaths(HSOpts.ResourceDir, "4.7.0");
  368. // mingw.org C++ include paths
  369. AddMinGWCPlusPlusIncludePaths("/mingw/lib/gcc", "mingw32", "4.5.2"); //MSYS
  370. AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", "mingw32", "4.5.0");
  371. AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", "mingw32", "4.4.0");
  372. AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", "mingw32", "4.3.0");
  373. break;
  374. case llvm::Triple::DragonFly:
  375. AddPath("/usr/include/c++/4.1", CXXSystem, true, false, false);
  376. break;
  377. case llvm::Triple::Linux:
  378. //===------------------------------------------------------------------===//
  379. // Debian based distros.
  380. // Note: these distros symlink /usr/include/c++/X.Y.Z -> X.Y
  381. //===------------------------------------------------------------------===//
  382. // Ubuntu 11.11 "Oneiric Ocelot" -- gcc-4.6.0
  383. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6",
  384. "x86_64-linux-gnu", "32", "", triple);
  385. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6",
  386. "i686-linux-gnu", "", "64", triple);
  387. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6",
  388. "i486-linux-gnu", "", "64", triple);
  389. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6",
  390. "arm-linux-gnueabi", "", "", triple);
  391. // Ubuntu 11.04 "Natty Narwhal" -- gcc-4.5.2
  392. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5",
  393. "x86_64-linux-gnu", "32", "", triple);
  394. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5",
  395. "i686-linux-gnu", "", "64", triple);
  396. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5",
  397. "i486-linux-gnu", "", "64", triple);
  398. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5",
  399. "arm-linux-gnueabi", "", "", triple);
  400. // Ubuntu 10.10 "Maverick Meerkat" -- gcc-4.4.5
  401. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4",
  402. "i686-linux-gnu", "", "64", triple);
  403. // The rest of 10.10 is the same as previous versions.
  404. // Ubuntu 10.04 LTS "Lucid Lynx" -- gcc-4.4.3
  405. // Ubuntu 9.10 "Karmic Koala" -- gcc-4.4.1
  406. // Debian 6.0 "squeeze" -- gcc-4.4.2
  407. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4",
  408. "x86_64-linux-gnu", "32", "", triple);
  409. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4",
  410. "i486-linux-gnu", "", "64", triple);
  411. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4",
  412. "arm-linux-gnueabi", "", "", triple);
  413. // Ubuntu 9.04 "Jaunty Jackalope" -- gcc-4.3.3
  414. // Ubuntu 8.10 "Intrepid Ibex" -- gcc-4.3.2
  415. // Debian 5.0 "lenny" -- gcc-4.3.2
  416. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3",
  417. "x86_64-linux-gnu", "32", "", triple);
  418. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3",
  419. "i486-linux-gnu", "", "64", triple);
  420. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3",
  421. "arm-linux-gnueabi", "", "", triple);
  422. // Ubuntu 8.04.4 LTS "Hardy Heron" -- gcc-4.2.4
  423. // Ubuntu 8.04.[0-3] LTS "Hardy Heron" -- gcc-4.2.3
  424. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2",
  425. "x86_64-linux-gnu", "32", "", triple);
  426. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2",
  427. "i486-linux-gnu", "", "64", triple);
  428. // Ubuntu 7.10 "Gutsy Gibbon" -- gcc-4.1.3
  429. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1",
  430. "x86_64-linux-gnu", "32", "", triple);
  431. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1",
  432. "i486-linux-gnu", "", "64", triple);
  433. //===------------------------------------------------------------------===//
  434. // Redhat based distros.
  435. //===------------------------------------------------------------------===//
  436. // Fedora 15 (GCC 4.6.1)
  437. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.1",
  438. "x86_64-redhat-linux", "32", "", triple);
  439. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.1",
  440. "i686-redhat-linux", "", "", triple);
  441. // Fedora 15 (GCC 4.6.0)
  442. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.0",
  443. "x86_64-redhat-linux", "32", "", triple);
  444. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.0",
  445. "i686-redhat-linux", "", "", triple);
  446. // Fedora 14
  447. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5.1",
  448. "x86_64-redhat-linux", "32", "", triple);
  449. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5.1",
  450. "i686-redhat-linux", "", "", triple);
  451. // RHEL5(gcc44)
  452. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.4",
  453. "x86_64-redhat-linux6E", "32", "", triple);
  454. // Fedora 13
  455. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.4",
  456. "x86_64-redhat-linux", "32", "", triple);
  457. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.4",
  458. "i686-redhat-linux","", "", triple);
  459. // Fedora 12
  460. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.3",
  461. "x86_64-redhat-linux", "32", "", triple);
  462. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.3",
  463. "i686-redhat-linux","", "", triple);
  464. // Fedora 12 (pre-FEB-2010)
  465. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.2",
  466. "x86_64-redhat-linux", "32", "", triple);
  467. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.2",
  468. "i686-redhat-linux","", "", triple);
  469. // Fedora 11
  470. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.1",
  471. "x86_64-redhat-linux", "32", "", triple);
  472. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.1",
  473. "i586-redhat-linux","", "", triple);
  474. // Fedora 10
  475. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.2",
  476. "x86_64-redhat-linux", "32", "", triple);
  477. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.2",
  478. "i386-redhat-linux","", "", triple);
  479. // Fedora 9
  480. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.0",
  481. "x86_64-redhat-linux", "32", "", triple);
  482. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.0",
  483. "i386-redhat-linux", "", "", triple);
  484. // Fedora 8
  485. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1.2",
  486. "x86_64-redhat-linux", "", "", triple);
  487. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1.2",
  488. "i386-redhat-linux", "", "", triple);
  489. // RHEL 5
  490. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1.1",
  491. "x86_64-redhat-linux", "32", "", triple);
  492. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1.1",
  493. "i386-redhat-linux", "", "", triple);
  494. //===------------------------------------------------------------------===//
  495. // Exherbo (2010-01-25)
  496. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.3",
  497. "x86_64-pc-linux-gnu", "32", "", triple);
  498. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.3",
  499. "i686-pc-linux-gnu", "", "", triple);
  500. // openSUSE 11.1 32 bit
  501. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3",
  502. "i586-suse-linux", "", "", triple);
  503. // openSUSE 11.1 64 bit
  504. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3",
  505. "x86_64-suse-linux", "32", "", triple);
  506. // openSUSE 11.2
  507. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4",
  508. "i586-suse-linux", "", "", triple);
  509. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4",
  510. "x86_64-suse-linux", "", "", triple);
  511. // openSUSE 11.4
  512. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5",
  513. "i586-suse-linux", "", "", triple);
  514. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5",
  515. "x86_64-suse-linux", "", "", triple);
  516. // openSUSE 12.1
  517. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6",
  518. "i586-suse-linux", "", "", triple);
  519. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6",
  520. "x86_64-suse-linux", "", "", triple);
  521. // Arch Linux 2008-06-24
  522. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.1",
  523. "i686-pc-linux-gnu", "", "", triple);
  524. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.1",
  525. "x86_64-unknown-linux-gnu", "", "", triple);
  526. // Arch Linux gcc 4.6
  527. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.1",
  528. "i686-pc-linux-gnu", "", "", triple);
  529. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.1",
  530. "x86_64-unknown-linux-gnu", "", "", triple);
  531. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.0",
  532. "i686-pc-linux-gnu", "", "", triple);
  533. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.6.0",
  534. "x86_64-unknown-linux-gnu", "", "", triple);
  535. // Slackware gcc 4.5.2 (13.37)
  536. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5.2",
  537. "i486-slackware-linux", "", "", triple);
  538. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5.2",
  539. "x86_64-slackware-linux", "", "", triple);
  540. // Slackware gcc 4.5.3 (-current)
  541. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5.3",
  542. "i486-slackware-linux", "", "", triple);
  543. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.5.3",
  544. "x86_64-slackware-linux", "", "", triple);
  545. // Gentoo x86 gcc 4.5.3
  546. AddGnuCPlusPlusIncludePaths(
  547. "/usr/lib/gcc/i686-pc-linux-gnu/4.5.3/include/g++-v4",
  548. "i686-pc-linux-gnu", "", "", triple);
  549. // Gentoo x86 gcc 4.5.2
  550. AddGnuCPlusPlusIncludePaths(
  551. "/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/g++-v4",
  552. "i686-pc-linux-gnu", "", "", triple);
  553. // Gentoo x86 gcc 4.4.5
  554. AddGnuCPlusPlusIncludePaths(
  555. "/usr/lib/gcc/i686-pc-linux-gnu/4.4.5/include/g++-v4",
  556. "i686-pc-linux-gnu", "", "", triple);
  557. // Gentoo x86 gcc 4.4.4
  558. AddGnuCPlusPlusIncludePaths(
  559. "/usr/lib/gcc/i686-pc-linux-gnu/4.4.4/include/g++-v4",
  560. "i686-pc-linux-gnu", "", "", triple);
  561. // Gentoo x86 2010.0 stable
  562. AddGnuCPlusPlusIncludePaths(
  563. "/usr/lib/gcc/i686-pc-linux-gnu/4.4.3/include/g++-v4",
  564. "i686-pc-linux-gnu", "", "", triple);
  565. // Gentoo x86 2009.1 stable
  566. AddGnuCPlusPlusIncludePaths(
  567. "/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4",
  568. "i686-pc-linux-gnu", "", "", triple);
  569. // Gentoo x86 2009.0 stable
  570. AddGnuCPlusPlusIncludePaths(
  571. "/usr/lib/gcc/i686-pc-linux-gnu/4.3.2/include/g++-v4",
  572. "i686-pc-linux-gnu", "", "", triple);
  573. // Gentoo x86 2008.0 stable
  574. AddGnuCPlusPlusIncludePaths(
  575. "/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4",
  576. "i686-pc-linux-gnu", "", "", triple);
  577. // Gentoo x86 llvm-gcc trunk
  578. AddGnuCPlusPlusIncludePaths(
  579. "/usr/lib/llvm-gcc-4.2-9999/include/c++/4.2.1",
  580. "i686-pc-linux-gnu", "", "", triple);
  581. // Gentoo amd64 gcc 4.5.3
  582. AddGnuCPlusPlusIncludePaths(
  583. "/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/include/g++-v4",
  584. "x86_64-pc-linux-gnu", "32", "", triple);
  585. // Gentoo amd64 gcc 4.5.2
  586. AddGnuCPlusPlusIncludePaths(
  587. "/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/include/g++-v4",
  588. "x86_64-pc-linux-gnu", "32", "", triple);
  589. // Gentoo amd64 gcc 4.4.5
  590. AddGnuCPlusPlusIncludePaths(
  591. "/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.5/include/g++-v4",
  592. "x86_64-pc-linux-gnu", "32", "", triple);
  593. // Gentoo amd64 gcc 4.4.4
  594. AddGnuCPlusPlusIncludePaths(
  595. "/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.4/include/g++-v4",
  596. "x86_64-pc-linux-gnu", "32", "", triple);
  597. // Gentoo amd64 gcc 4.4.3
  598. AddGnuCPlusPlusIncludePaths(
  599. "/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.3/include/g++-v4",
  600. "x86_64-pc-linux-gnu", "32", "", triple);
  601. // Gentoo amd64 gcc 4.3.4
  602. AddGnuCPlusPlusIncludePaths(
  603. "/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.4/include/g++-v4",
  604. "x86_64-pc-linux-gnu", "", "", triple);
  605. // Gentoo amd64 gcc 4.3.2
  606. AddGnuCPlusPlusIncludePaths(
  607. "/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/include/g++-v4",
  608. "x86_64-pc-linux-gnu", "", "", triple);
  609. // Gentoo amd64 stable
  610. AddGnuCPlusPlusIncludePaths(
  611. "/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/include/g++-v4",
  612. "x86_64-pc-linux-gnu", "", "", triple);
  613. // Gentoo amd64 llvm-gcc trunk
  614. AddGnuCPlusPlusIncludePaths(
  615. "/usr/lib/llvm-gcc-4.2-9999/include/c++/4.2.1",
  616. "x86_64-pc-linux-gnu", "", "", triple);
  617. break;
  618. case llvm::Triple::FreeBSD:
  619. // FreeBSD 8.0
  620. // FreeBSD 7.3
  621. AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2", "", "", "", triple);
  622. break;
  623. case llvm::Triple::NetBSD:
  624. AddGnuCPlusPlusIncludePaths("/usr/include/g++", "", "", "", triple);
  625. break;
  626. case llvm::Triple::OpenBSD: {
  627. std::string t = triple.getTriple();
  628. if (t.substr(0, 6) == "x86_64")
  629. t.replace(0, 6, "amd64");
  630. AddGnuCPlusPlusIncludePaths("/usr/include/g++",
  631. t, "", "", triple);
  632. break;
  633. }
  634. case llvm::Triple::Minix:
  635. AddGnuCPlusPlusIncludePaths("/usr/gnu/include/c++/4.4.3",
  636. "", "", "", triple);
  637. break;
  638. case llvm::Triple::Solaris:
  639. // Solaris - Fall though..
  640. case llvm::Triple::AuroraUX:
  641. // AuroraUX
  642. AddGnuCPlusPlusIncludePaths("/opt/gcc4/include/c++/4.2.4",
  643. "i386-pc-solaris2.11", "", "", triple);
  644. break;
  645. default:
  646. break;
  647. }
  648. }
  649. void InitHeaderSearch::AddDefaultIncludePaths(const LangOptions &Lang,
  650. const llvm::Triple &triple,
  651. const HeaderSearchOptions &HSOpts) {
  652. // NB: This code path is going away. All of the logic is moving into the
  653. // driver which has the information necessary to do target-specific
  654. // selections of default include paths. Each target which moves there will be
  655. // exempted from this logic here until we can delete the entire pile of code.
  656. switch (triple.getOS()) {
  657. default:
  658. break; // Everything else continues to use this routine's logic.
  659. case llvm::Triple::Win32:
  660. return;
  661. }
  662. if (Lang.CPlusPlus && HSOpts.UseStandardCXXIncludes &&
  663. HSOpts.UseStandardSystemIncludes) {
  664. if (HSOpts.UseLibcxx) {
  665. if (triple.isOSDarwin()) {
  666. // On Darwin, libc++ may be installed alongside the compiler in
  667. // lib/c++/v1.
  668. llvm::sys::Path P(HSOpts.ResourceDir);
  669. if (!P.isEmpty()) {
  670. P.eraseComponent(); // Remove version from foo/lib/clang/version
  671. P.eraseComponent(); // Remove clang from foo/lib/clang
  672. // Get foo/lib/c++/v1
  673. P.appendComponent("c++");
  674. P.appendComponent("v1");
  675. AddPath(P.str(), CXXSystem, true, false, false, true);
  676. }
  677. }
  678. AddPath("/usr/include/c++/v1", CXXSystem, true, false, false);
  679. } else {
  680. AddDefaultCPlusPlusIncludePaths(triple, HSOpts);
  681. }
  682. }
  683. AddDefaultCIncludePaths(triple, HSOpts);
  684. // Add the default framework include paths on Darwin.
  685. if (HSOpts.UseStandardSystemIncludes) {
  686. if (triple.isOSDarwin()) {
  687. AddPath("/System/Library/Frameworks", System, true, false, true);
  688. AddPath("/Library/Frameworks", System, true, false, true);
  689. }
  690. }
  691. }
  692. /// RemoveDuplicates - If there are duplicate directory entries in the specified
  693. /// search list, remove the later (dead) ones. Returns the number of non-system
  694. /// headers removed, which is used to update NumAngled.
  695. static unsigned RemoveDuplicates(std::vector<DirectoryLookup> &SearchList,
  696. unsigned First, bool Verbose) {
  697. llvm::SmallPtrSet<const DirectoryEntry *, 8> SeenDirs;
  698. llvm::SmallPtrSet<const DirectoryEntry *, 8> SeenFrameworkDirs;
  699. llvm::SmallPtrSet<const HeaderMap *, 8> SeenHeaderMaps;
  700. unsigned NonSystemRemoved = 0;
  701. for (unsigned i = First; i != SearchList.size(); ++i) {
  702. unsigned DirToRemove = i;
  703. const DirectoryLookup &CurEntry = SearchList[i];
  704. if (CurEntry.isNormalDir()) {
  705. // If this isn't the first time we've seen this dir, remove it.
  706. if (SeenDirs.insert(CurEntry.getDir()))
  707. continue;
  708. } else if (CurEntry.isFramework()) {
  709. // If this isn't the first time we've seen this framework dir, remove it.
  710. if (SeenFrameworkDirs.insert(CurEntry.getFrameworkDir()))
  711. continue;
  712. } else {
  713. assert(CurEntry.isHeaderMap() && "Not a headermap or normal dir?");
  714. // If this isn't the first time we've seen this headermap, remove it.
  715. if (SeenHeaderMaps.insert(CurEntry.getHeaderMap()))
  716. continue;
  717. }
  718. // If we have a normal #include dir/framework/headermap that is shadowed
  719. // later in the chain by a system include location, we actually want to
  720. // ignore the user's request and drop the user dir... keeping the system
  721. // dir. This is weird, but required to emulate GCC's search path correctly.
  722. //
  723. // Since dupes of system dirs are rare, just rescan to find the original
  724. // that we're nuking instead of using a DenseMap.
  725. if (CurEntry.getDirCharacteristic() != SrcMgr::C_User) {
  726. // Find the dir that this is the same of.
  727. unsigned FirstDir;
  728. for (FirstDir = 0; ; ++FirstDir) {
  729. assert(FirstDir != i && "Didn't find dupe?");
  730. const DirectoryLookup &SearchEntry = SearchList[FirstDir];
  731. // If these are different lookup types, then they can't be the dupe.
  732. if (SearchEntry.getLookupType() != CurEntry.getLookupType())
  733. continue;
  734. bool isSame;
  735. if (CurEntry.isNormalDir())
  736. isSame = SearchEntry.getDir() == CurEntry.getDir();
  737. else if (CurEntry.isFramework())
  738. isSame = SearchEntry.getFrameworkDir() == CurEntry.getFrameworkDir();
  739. else {
  740. assert(CurEntry.isHeaderMap() && "Not a headermap or normal dir?");
  741. isSame = SearchEntry.getHeaderMap() == CurEntry.getHeaderMap();
  742. }
  743. if (isSame)
  744. break;
  745. }
  746. // If the first dir in the search path is a non-system dir, zap it
  747. // instead of the system one.
  748. if (SearchList[FirstDir].getDirCharacteristic() == SrcMgr::C_User)
  749. DirToRemove = FirstDir;
  750. }
  751. if (Verbose) {
  752. llvm::errs() << "ignoring duplicate directory \""
  753. << CurEntry.getName() << "\"\n";
  754. if (DirToRemove != i)
  755. llvm::errs() << " as it is a non-system directory that duplicates "
  756. << "a system directory\n";
  757. }
  758. if (DirToRemove != i)
  759. ++NonSystemRemoved;
  760. // This is reached if the current entry is a duplicate. Remove the
  761. // DirToRemove (usually the current dir).
  762. SearchList.erase(SearchList.begin()+DirToRemove);
  763. --i;
  764. }
  765. return NonSystemRemoved;
  766. }
  767. void InitHeaderSearch::Realize(const LangOptions &Lang) {
  768. // Concatenate ANGLE+SYSTEM+AFTER chains together into SearchList.
  769. std::vector<DirectoryLookup> SearchList;
  770. SearchList.reserve(IncludePath.size());
  771. // Quoted arguments go first.
  772. for (path_iterator it = IncludePath.begin(), ie = IncludePath.end();
  773. it != ie; ++it) {
  774. if (it->first == Quoted)
  775. SearchList.push_back(it->second);
  776. }
  777. // Deduplicate and remember index.
  778. RemoveDuplicates(SearchList, 0, Verbose);
  779. unsigned NumQuoted = SearchList.size();
  780. for (path_iterator it = IncludePath.begin(), ie = IncludePath.end();
  781. it != ie; ++it) {
  782. if (it->first == Angled || it->first == IndexHeaderMap)
  783. SearchList.push_back(it->second);
  784. }
  785. RemoveDuplicates(SearchList, NumQuoted, Verbose);
  786. unsigned NumAngled = SearchList.size();
  787. for (path_iterator it = IncludePath.begin(), ie = IncludePath.end();
  788. it != ie; ++it) {
  789. if (it->first == System ||
  790. (!Lang.ObjC1 && !Lang.CPlusPlus && it->first == CSystem) ||
  791. (/*FIXME !Lang.ObjC1 && */Lang.CPlusPlus && it->first == CXXSystem) ||
  792. (Lang.ObjC1 && !Lang.CPlusPlus && it->first == ObjCSystem) ||
  793. (Lang.ObjC1 && Lang.CPlusPlus && it->first == ObjCXXSystem))
  794. SearchList.push_back(it->second);
  795. }
  796. for (path_iterator it = IncludePath.begin(), ie = IncludePath.end();
  797. it != ie; ++it) {
  798. if (it->first == After)
  799. SearchList.push_back(it->second);
  800. }
  801. // Remove duplicates across both the Angled and System directories. GCC does
  802. // this and failing to remove duplicates across these two groups breaks
  803. // #include_next.
  804. unsigned NonSystemRemoved = RemoveDuplicates(SearchList, NumQuoted, Verbose);
  805. NumAngled -= NonSystemRemoved;
  806. bool DontSearchCurDir = false; // TODO: set to true if -I- is set?
  807. Headers.SetSearchPaths(SearchList, NumQuoted, NumAngled, DontSearchCurDir);
  808. // If verbose, print the list of directories that will be searched.
  809. if (Verbose) {
  810. llvm::errs() << "#include \"...\" search starts here:\n";
  811. for (unsigned i = 0, e = SearchList.size(); i != e; ++i) {
  812. if (i == NumQuoted)
  813. llvm::errs() << "#include <...> search starts here:\n";
  814. const char *Name = SearchList[i].getName();
  815. const char *Suffix;
  816. if (SearchList[i].isNormalDir())
  817. Suffix = "";
  818. else if (SearchList[i].isFramework())
  819. Suffix = " (framework directory)";
  820. else {
  821. assert(SearchList[i].isHeaderMap() && "Unknown DirectoryLookup");
  822. Suffix = " (headermap)";
  823. }
  824. llvm::errs() << " " << Name << Suffix << "\n";
  825. }
  826. llvm::errs() << "End of search list.\n";
  827. }
  828. }
  829. void clang::ApplyHeaderSearchOptions(HeaderSearch &HS,
  830. const HeaderSearchOptions &HSOpts,
  831. const LangOptions &Lang,
  832. const llvm::Triple &Triple) {
  833. InitHeaderSearch Init(HS, HSOpts.Verbose, HSOpts.Sysroot);
  834. // Add the user defined entries.
  835. for (unsigned i = 0, e = HSOpts.UserEntries.size(); i != e; ++i) {
  836. const HeaderSearchOptions::Entry &E = HSOpts.UserEntries[i];
  837. Init.AddPath(E.Path, E.Group, !E.ImplicitExternC, E.IsUserSupplied,
  838. E.IsFramework, E.IgnoreSysRoot);
  839. }
  840. Init.AddDefaultIncludePaths(Lang, Triple, HSOpts);
  841. Init.Realize(Lang);
  842. }