summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/InitHeaderSearch.cpp
diff options
context:
space:
mode:
authorLouis Dionne <ldionne@apple.com>2019-05-21 17:48:04 +0000
committerLouis Dionne <ldionne@apple.com>2019-05-21 17:48:04 +0000
commite97b5f5cf37e382643b567affd714823215d0e75 (patch)
tree2e8d6ed7833c20d2733478b92d5635833940fc2b /clang/lib/Frontend/InitHeaderSearch.cpp
parentb7a19321442a5c78ea463fe9a9c671d2522788ee (diff)
downloadbcm5719-llvm-e97b5f5cf37e382643b567affd714823215d0e75.tar.gz
bcm5719-llvm-e97b5f5cf37e382643b567affd714823215d0e75.zip
[clang][Darwin] Refactor header search path logic into the driver
Summary: This commit moves the logic for determining system, resource and C++ header search paths from CC1 to the driver. This refactor has already been made for several platforms, but Darwin had been left behind. This refactor tries to implement the previous search path logic with perfect accuracy. In particular, the order of all include paths inside CC1 and all paths that were skipped because nonexistent are conserved after the refactor. This change was also tested against a code base of significant size and revealed no problems. Reviewers: jfb, arphaman Subscribers: nemanjai, javed.absar, kbarton, christof, jkorous, dexonsmith, jsji, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61963 llvm-svn: 361278
Diffstat (limited to 'clang/lib/Frontend/InitHeaderSearch.cpp')
-rw-r--r--clang/lib/Frontend/InitHeaderSearch.cpp66
1 files changed, 15 insertions, 51 deletions
diff --git a/clang/lib/Frontend/InitHeaderSearch.cpp b/clang/lib/Frontend/InitHeaderSearch.cpp
index d96fa81f73f..e6cd8235b01 100644
--- a/clang/lib/Frontend/InitHeaderSearch.cpp
+++ b/clang/lib/Frontend/InitHeaderSearch.cpp
@@ -210,6 +210,10 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
const HeaderSearchOptions &HSOpts) {
llvm::Triple::OSType os = triple.getOS();
+ if (triple.isOSDarwin()) {
+ llvm_unreachable("Include management is handled in the driver.");
+ }
+
if (HSOpts.UseStandardSystemIncludes) {
switch (os) {
case llvm::Triple::CloudABI:
@@ -365,49 +369,7 @@ void InitHeaderSearch::AddDefaultCPlusPlusIncludePaths(
// FIXME: temporary hack: hard-coded paths.
if (triple.isOSDarwin()) {
- bool IsBaseFound = true;
- switch (triple.getArch()) {
- default: break;
-
- case llvm::Triple::ppc:
- case llvm::Triple::ppc64:
- IsBaseFound = AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
- "powerpc-apple-darwin10", "",
- "ppc64", triple);
- IsBaseFound |= AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.0.0",
- "powerpc-apple-darwin10", "",
- "ppc64", triple);
- break;
-
- case llvm::Triple::x86:
- case llvm::Triple::x86_64:
- IsBaseFound = AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
- "i686-apple-darwin10", "",
- "x86_64", triple);
- IsBaseFound |= AddGnuCPlusPlusIncludePaths(
- "/usr/include/c++/4.0.0", "i686-apple-darwin8", "", "", triple);
- break;
-
- case llvm::Triple::arm:
- case llvm::Triple::thumb:
- IsBaseFound = AddGnuCPlusPlusIncludePaths(
- "/usr/include/c++/4.2.1", "arm-apple-darwin10", "v7", "", triple);
- IsBaseFound |= AddGnuCPlusPlusIncludePaths(
- "/usr/include/c++/4.2.1", "arm-apple-darwin10", "v6", "", triple);
- break;
-
- case llvm::Triple::aarch64:
- IsBaseFound = AddGnuCPlusPlusIncludePaths(
- "/usr/include/c++/4.2.1", "arm64-apple-darwin10", "", "", triple);
- break;
- }
- // Warn when compiling pure C++ / Objective-C++ only.
- if (!IsBaseFound &&
- !(LangOpts.CUDA || LangOpts.OpenCL || LangOpts.RenderScript)) {
- Headers.getDiags().Report(SourceLocation(),
- diag::warn_stdlibcxx_not_found);
- }
- return;
+ llvm_unreachable("Include management is handled in the driver.");
}
switch (os) {
@@ -464,6 +426,16 @@ void InitHeaderSearch::AddDefaultIncludePaths(const LangOptions &Lang,
break;
}
+ // All header search logic is handled in the Driver for Darwin.
+ if (triple.isOSDarwin()) {
+ if (HSOpts.UseStandardSystemIncludes) {
+ // Add the default framework include paths on Darwin.
+ AddPath("/System/Library/Frameworks", System, true);
+ AddPath("/Library/Frameworks", System, true);
+ }
+ return;
+ }
+
if (Lang.CPlusPlus && !Lang.AsmPreprocessor &&
HSOpts.UseStandardCXXIncludes && HSOpts.UseStandardSystemIncludes) {
if (HSOpts.UseLibcxx) {
@@ -474,14 +446,6 @@ void InitHeaderSearch::AddDefaultIncludePaths(const LangOptions &Lang,
}
AddDefaultCIncludePaths(triple, HSOpts);
-
- // Add the default framework include paths on Darwin.
- if (HSOpts.UseStandardSystemIncludes) {
- if (triple.isOSDarwin()) {
- AddPath("/System/Library/Frameworks", System, true);
- AddPath("/Library/Frameworks", System, true);
- }
- }
}
/// RemoveDuplicates - If there are duplicate directory entries in the specified
OpenPOWER on IntegriCloud