diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Driver/Job.cpp | 17 | ||||
-rw-r--r-- | clang/lib/Driver/ToolChain.cpp | 40 | ||||
-rw-r--r-- | clang/lib/Driver/ToolChains/Darwin.cpp | 21 | ||||
-rw-r--r-- | clang/lib/Driver/ToolChains/Darwin.h | 4 | ||||
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Lex/InitHeaderSearch.cpp | 19 |
6 files changed, 69 insertions, 36 deletions
diff --git a/clang/lib/Driver/Job.cpp b/clang/lib/Driver/Job.cpp index 4619b8c..f676b12 100644 --- a/clang/lib/Driver/Job.cpp +++ b/clang/lib/Driver/Job.cpp @@ -67,14 +67,15 @@ static bool skipArgs(const char *Flag, bool HaveCrashVFS, int &SkipNum, return true; // Some include flags shouldn't be skipped if we have a crash VFS - IsInclude = llvm::StringSwitch<bool>(Flag) - .Cases("-include", "-header-include-file", true) - .Cases("-idirafter", "-internal-isystem", "-iwithprefix", true) - .Cases("-internal-externc-isystem", "-iprefix", true) - .Cases("-iwithprefixbefore", "-isystem", "-iquote", true) - .Cases("-isysroot", "-I", "-F", "-resource-dir", true) - .Cases("-iframework", "-include-pch", true) - .Default(false); + IsInclude = + llvm::StringSwitch<bool>(Flag) + .Cases("-include", "-header-include-file", true) + .Cases("-idirafter", "-internal-isystem", "-iwithprefix", true) + .Cases("-internal-externc-isystem", "-iprefix", true) + .Cases("-iwithprefixbefore", "-isystem", "-iquote", true) + .Cases("-isysroot", "-I", "-F", "-resource-dir", true) + .Cases("-internal-iframework", "-iframework", "-include-pch", true) + .Default(false); if (IsInclude) return !HaveCrashVFS; diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 5cd5755..3c52abb 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -1366,10 +1366,17 @@ ToolChain::CXXStdlibType ToolChain::GetCXXStdlibType(const ArgList &Args) const{ return *cxxStdlibType; } +/// Utility function to add a system framework directory to CC1 arguments. +void ToolChain::addSystemFrameworkInclude(const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args, + const Twine &Path) { + CC1Args.push_back("-internal-iframework"); + CC1Args.push_back(DriverArgs.MakeArgString(Path)); +} + /// Utility function to add a system include directory to CC1 arguments. -/*static*/ void ToolChain::addSystemInclude(const ArgList &DriverArgs, - ArgStringList &CC1Args, - const Twine &Path) { +void ToolChain::addSystemInclude(const ArgList &DriverArgs, + ArgStringList &CC1Args, const Twine &Path) { CC1Args.push_back("-internal-isystem"); CC1Args.push_back(DriverArgs.MakeArgString(Path)); } @@ -1382,9 +1389,9 @@ ToolChain::CXXStdlibType ToolChain::GetCXXStdlibType(const ArgList &Args) const{ /// "C" semantics. These semantics are *ignored* by and large today, but its /// important to preserve the preprocessor changes resulting from the /// classification. -/*static*/ void ToolChain::addExternCSystemInclude(const ArgList &DriverArgs, - ArgStringList &CC1Args, - const Twine &Path) { +void ToolChain::addExternCSystemInclude(const ArgList &DriverArgs, + ArgStringList &CC1Args, + const Twine &Path) { CC1Args.push_back("-internal-externc-isystem"); CC1Args.push_back(DriverArgs.MakeArgString(Path)); } @@ -1396,19 +1403,28 @@ void ToolChain::addExternCSystemIncludeIfExists(const ArgList &DriverArgs, addExternCSystemInclude(DriverArgs, CC1Args, Path); } +/// Utility function to add a list of system framework directories to CC1. +void ToolChain::addSystemFrameworkIncludes(const ArgList &DriverArgs, + ArgStringList &CC1Args, + ArrayRef<StringRef> Paths) { + for (const auto &Path : Paths) { + CC1Args.push_back("-internal-iframework"); + CC1Args.push_back(DriverArgs.MakeArgString(Path)); + } +} + /// Utility function to add a list of system include directories to CC1. -/*static*/ void ToolChain::addSystemIncludes(const ArgList &DriverArgs, - ArgStringList &CC1Args, - ArrayRef<StringRef> Paths) { +void ToolChain::addSystemIncludes(const ArgList &DriverArgs, + ArgStringList &CC1Args, + ArrayRef<StringRef> Paths) { for (const auto &Path : Paths) { CC1Args.push_back("-internal-isystem"); CC1Args.push_back(DriverArgs.MakeArgString(Path)); } } -/*static*/ std::string ToolChain::concat(StringRef Path, const Twine &A, - const Twine &B, const Twine &C, - const Twine &D) { +std::string ToolChain::concat(StringRef Path, const Twine &A, const Twine &B, + const Twine &C, const Twine &D) { SmallString<128> Result(Path); llvm::sys::path::append(Result, llvm::sys::path::Style::posix, A, B, C, D); return std::string(Result); diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index 4735dc3..76fa2d1 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -2577,6 +2577,27 @@ void AppleMachO::AddClangSystemIncludeArgs( } } +void DarwinClang::AddClangSystemIncludeArgs( + const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args) const { + AppleMachO::AddClangSystemIncludeArgs(DriverArgs, CC1Args); + + if (DriverArgs.hasArg(options::OPT_nostdinc) || + DriverArgs.hasArg(options::OPT_nostdlibinc)) + return; + + llvm::SmallString<128> Sysroot = GetEffectiveSysroot(DriverArgs); + + // Add <sysroot>/System/Library/Frameworks + // Add <sysroot>/System/Library/SubFrameworks + // Add <sysroot>/Library/Frameworks + SmallString<128> P1(Sysroot), P2(Sysroot), P3(Sysroot); + llvm::sys::path::append(P1, "System", "Library", "Frameworks"); + llvm::sys::path::append(P2, "System", "Library", "SubFrameworks"); + llvm::sys::path::append(P3, "Library", "Frameworks"); + addSystemFrameworkIncludes(DriverArgs, CC1Args, {P1, P2, P3}); +} + bool DarwinClang::AddGnuCPlusPlusIncludePaths(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, llvm::SmallString<128> Base, diff --git a/clang/lib/Driver/ToolChains/Darwin.h b/clang/lib/Driver/ToolChains/Darwin.h index 76523d6..b38bfe6 100644 --- a/clang/lib/Driver/ToolChains/Darwin.h +++ b/clang/lib/Driver/ToolChains/Darwin.h @@ -647,6 +647,10 @@ public: /// @name Apple ToolChain Implementation /// { + void + AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args) const override; + RuntimeLibType GetRuntimeLibType(const llvm::opt::ArgList &Args) const override; void AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args, diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index a0b8bbf..3945129 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -3373,6 +3373,8 @@ static void GenerateHeaderSearchArgs(const HeaderSearchOptions &Opts, : OPT_internal_externc_isystem; GenerateArg(Consumer, Opt, It->Path); } + for (; It < End && Matches(*It, {frontend::System}, true, true); ++It) + GenerateArg(Consumer, OPT_internal_iframework, It->Path); assert(It == End && "Unhandled HeaderSearchOption::Entry."); @@ -3505,6 +3507,8 @@ static bool ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args, Group = frontend::ExternCSystem; Opts.AddPath(A->getValue(), Group, false, true); } + for (const auto *A : Args.filtered(OPT_internal_iframework)) + Opts.AddPath(A->getValue(), frontend::System, true, true); // Add the path prefixes which are implicitly treated as being system headers. for (const auto *A : diff --git a/clang/lib/Lex/InitHeaderSearch.cpp b/clang/lib/Lex/InitHeaderSearch.cpp index bb2a213..df45c967 100644 --- a/clang/lib/Lex/InitHeaderSearch.cpp +++ b/clang/lib/Lex/InitHeaderSearch.cpp @@ -321,6 +321,9 @@ bool InitHeaderSearch::ShouldAddDefaultIncludePaths( break; } + if (triple.isOSDarwin()) + return false; + return true; // Everything else uses AddDefaultIncludePaths(). } @@ -335,22 +338,6 @@ void InitHeaderSearch::AddDefaultIncludePaths( if (!ShouldAddDefaultIncludePaths(triple)) return; - // NOTE: some additional header search logic is handled in the driver for - // Darwin. - if (triple.isOSDarwin()) { - if (HSOpts.UseStandardSystemIncludes) { - // Add the default framework include paths on Darwin. - if (triple.isDriverKit()) { - AddPath("/System/DriverKit/System/Library/Frameworks", System, true); - } else { - AddPath("/System/Library/Frameworks", System, true); - AddPath("/System/Library/SubFrameworks", System, true); - AddPath("/Library/Frameworks", System, true); - } - } - return; - } - if (Lang.CPlusPlus && !Lang.AsmPreprocessor && HSOpts.UseStandardCXXIncludes && HSOpts.UseStandardSystemIncludes) { if (HSOpts.UseLibcxx) { |