diff options
author | Daniel Dunbar <daniel@zuster.org> | 2011-10-11 18:20:10 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2011-10-11 18:20:10 +0000 |
commit | a268fc0f2229eb132ebc8501b140093aeb5516bf (patch) | |
tree | 3501279fb65bb5690344b0def51896dd02d3faf4 /lib/Frontend/InitHeaderSearch.cpp | |
parent | 71fdf469a3b6d7d557b0bfba36e8659f4966c565 (diff) |
Frontend: Replace -nostdinc by -nostdsysteminc (which is just system include
paths). The -nostdinc behavior is now -nostdsysteminc + -nobuiltininc.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141691 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/InitHeaderSearch.cpp')
-rw-r--r-- | lib/Frontend/InitHeaderSearch.cpp | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/lib/Frontend/InitHeaderSearch.cpp b/lib/Frontend/InitHeaderSearch.cpp index 76cda2c9b3..b066e71a94 100644 --- a/lib/Frontend/InitHeaderSearch.cpp +++ b/lib/Frontend/InitHeaderSearch.cpp @@ -92,9 +92,9 @@ public: /// AddDefaultSystemIncludePaths - Adds the default system include paths so /// that e.g. stdio.h is found. - void AddDefaultSystemIncludePaths(const LangOptions &Lang, - const llvm::Triple &triple, - const HeaderSearchOptions &HSOpts); + void AddDefaultIncludePaths(const LangOptions &Lang, + const llvm::Triple &triple, + const HeaderSearchOptions &HSOpts); /// Realize - Merges all search path lists into one list and send it to /// HeaderSearch. @@ -424,14 +424,16 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple, const HeaderSearchOptions &HSOpts) { llvm::Triple::OSType os = triple.getOS(); - switch (os) { - case llvm::Triple::FreeBSD: - case llvm::Triple::NetBSD: - break; - default: - // FIXME: temporary hack: hard-coded paths. - AddPath("/usr/local/include", System, true, false, false); - break; + if (HSOpts.UseStandardSystemIncludes) { + switch (os) { + case llvm::Triple::FreeBSD: + case llvm::Triple::NetBSD: + break; + default: + // FIXME: temporary hack: hard-coded paths. + AddPath("/usr/local/include", System, true, false, false); + break; + } } // Builtin includes use #include_next directives and should be positioned @@ -444,6 +446,11 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple, AddPath(P.str(), System, false, false, false, /*IgnoreSysRoot=*/ true); } + // All remaining additions are for system include directories, early exit if + // we aren't using them. + if (!HSOpts.UseStandardSystemIncludes) + return; + // Add dirs specified via 'configure --with-c-include-dirs'. StringRef CIncludeDirs(C_INCLUDE_DIRS); if (CIncludeDirs != "") { @@ -932,10 +939,11 @@ AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple, const HeaderSearchOp } } -void InitHeaderSearch::AddDefaultSystemIncludePaths(const LangOptions &Lang, - const llvm::Triple &triple, +void InitHeaderSearch::AddDefaultIncludePaths(const LangOptions &Lang, + const llvm::Triple &triple, const HeaderSearchOptions &HSOpts) { - if (Lang.CPlusPlus && HSOpts.UseStandardCXXIncludes) { + if (Lang.CPlusPlus && HSOpts.UseStandardCXXIncludes && + HSOpts.UseStandardSystemIncludes) { if (HSOpts.UseLibcxx) { if (triple.isOSDarwin()) { // On Darwin, libc++ may be installed alongside the compiler in @@ -953,17 +961,19 @@ void InitHeaderSearch::AddDefaultSystemIncludePaths(const LangOptions &Lang, } AddPath("/usr/include/c++/v1", CXXSystem, true, false, false); - } - else + } else { AddDefaultCPlusPlusIncludePaths(triple, HSOpts); + } } AddDefaultCIncludePaths(triple, HSOpts); // Add the default framework include paths on Darwin. - if (triple.isOSDarwin()) { - AddPath("/System/Library/Frameworks", System, true, false, true); - AddPath("/Library/Frameworks", System, true, false, true); + if (HSOpts.UseStandardSystemIncludes) { + if (triple.isOSDarwin()) { + AddPath("/System/Library/Frameworks", System, true, false, true); + AddPath("/Library/Frameworks", System, true, false, true); + } } } @@ -1138,8 +1148,7 @@ void clang::ApplyHeaderSearchOptions(HeaderSearch &HS, E.IgnoreSysRoot); } - if (HSOpts.UseStandardIncludes) - Init.AddDefaultSystemIncludePaths(Lang, Triple, HSOpts); + Init.AddDefaultIncludePaths(Lang, Triple, HSOpts); Init.Realize(Lang); } |