"specify a MSP430 device, or -mhwmult to set hardware multiply type "
"explicitly.">, InGroup<InvalidCommandLineArgument>;
+def warn_drv_libstdcxx_not_found : Warning<
+ "include path for libstdc++ headers not found; pass '-stdlib=libc++' on the "
+ "command line to use the libc++ standard library instead">,
+ InGroup<DiagGroup<"stdlibcxx-not-found">>;
+
}
def warn_option_invalid_ocl_version : Warning<
"OpenCL version %0 does not support the option '%1'">, InGroup<Deprecated>;
-def warn_stdlibcxx_not_found : Warning<
- "include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the "
- "command line to use the libc++ standard library instead">,
- InGroup<DiagGroup<"stdlibcxx-not-found">>;
-
def err_builtin_needs_feature : Error<"%0 needs target feature %1">;
def err_function_needs_feature : Error<
"always_inline function %1 requires target feature '%2', but would "
#include "CommonArgs.h"
#include "clang/Basic/AlignedAllocation.h"
#include "clang/Basic/ObjCRuntime.h"
+#include "clang/Config/config.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/DriverDiagnostic.h"
}
}
+void DarwinClang::AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args) const {
+ const Driver &D = getDriver();
+
+ llvm::StringRef Sysroot = "/";
+ if (const Arg *A = DriverArgs.getLastArg(options::OPT_isysroot))
+ Sysroot = A->getValue();
+
+ bool NoStdInc = DriverArgs.hasArg(options::OPT_nostdinc);
+ bool NoStdlibInc = DriverArgs.hasArg(options::OPT_nostdlibinc);
+ bool NoBuiltinInc = DriverArgs.hasArg(options::OPT_nobuiltininc);
+
+ // Add <sysroot>/usr/local/include
+ if (!NoStdInc && !NoStdlibInc) {
+ SmallString<128> P(Sysroot);
+ llvm::sys::path::append(P, "usr", "local", "include");
+ addSystemInclude(DriverArgs, CC1Args, P);
+ }
+
+ // Add the Clang builtin headers (<resource>/include)
+ if (!NoStdInc && !NoBuiltinInc) {
+ SmallString<128> P(D.ResourceDir);
+ llvm::sys::path::append(P, "include");
+ addSystemInclude(DriverArgs, CC1Args, P);
+ }
+
+ if (NoStdInc || NoStdlibInc)
+ return;
+
+ // Check for configure-time C include directories.
+ llvm::StringRef CIncludeDirs(C_INCLUDE_DIRS);
+ if (!CIncludeDirs.empty()) {
+ llvm::SmallVector<llvm::StringRef, 5> dirs;
+ CIncludeDirs.split(dirs, ":");
+ for (llvm::StringRef dir : dirs) {
+ llvm::StringRef Prefix =
+ llvm::sys::path::is_absolute(dir) ? llvm::StringRef(Sysroot) : "";
+ addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
+ }
+ } else {
+ // Otherwise, add <sysroot>/usr/include.
+ SmallString<128> P(Sysroot);
+ llvm::sys::path::append(P, "usr", "include");
+ addExternCSystemInclude(DriverArgs, CC1Args, P.str());
+ }
+}
+
+bool DarwinClang::AddGnuCPlusPlusIncludePaths(const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args,
+ llvm::SmallString<128> Base,
+ llvm::StringRef Version,
+ llvm::StringRef ArchDir,
+ llvm::StringRef BitDir) const {
+ llvm::sys::path::append(Base, Version);
+
+ // Add the base dir
+ addSystemInclude(DriverArgs, CC1Args, Base);
+
+ // Add the multilib dirs
+ {
+ llvm::SmallString<128> P = Base;
+ if (!ArchDir.empty())
+ llvm::sys::path::append(P, ArchDir);
+ if (!BitDir.empty())
+ llvm::sys::path::append(P, BitDir);
+ addSystemInclude(DriverArgs, CC1Args, P);
+ }
+
+ // Add the backward dir
+ {
+ llvm::SmallString<128> P = Base;
+ llvm::sys::path::append(P, "backward");
+ addSystemInclude(DriverArgs, CC1Args, P);
+ }
+
+ return getVFS().exists(Base);
+}
+
void DarwinClang::AddClangCXXStdlibIncludeArgs(
const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const {
// CC1Args.
// FIXME: this should not be necessary, remove usages in the frontend
// (e.g. HeaderSearchOptions::UseLibcxx) and don't pipe -stdlib.
+ // Also check whether this is used for setting library search paths.
ToolChain::AddClangCXXStdlibIncludeArgs(DriverArgs, CC1Args);
if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
DriverArgs.hasArg(options::OPT_nostdincxx))
return;
+ llvm::SmallString<128> Sysroot;
+ if (const Arg *A = DriverArgs.getLastArg(options::OPT_isysroot)) {
+ Sysroot = A->getValue();
+ } else {
+ Sysroot = "/";
+ }
+
switch (GetCXXStdlibType(DriverArgs)) {
case ToolChain::CST_Libcxx: {
- llvm::StringRef InstallDir = getDriver().getInstalledDir();
- if (InstallDir.empty())
- break;
- // On Darwin, libc++ may be installed alongside the compiler in
- // include/c++/v1.
- // Get from 'foo/bin' to 'foo/include/c++/v1'.
- SmallString<128> P = InstallDir;
- // Note that InstallDir can be relative, so we have to '..' and not
- // parent_path.
- llvm::sys::path::append(P, "..", "include", "c++", "v1");
- addSystemInclude(DriverArgs, CC1Args, P);
+ // On Darwin, libc++ is installed alongside the compiler in
+ // include/c++/v1, so get from '<install>/bin' to '<install>/include/c++/v1'.
+ {
+ llvm::SmallString<128> P = llvm::StringRef(getDriver().getInstalledDir());
+ // Note that P can be relative, so we have to '..' and not parent_path.
+ llvm::sys::path::append(P, "..", "include", "c++", "v1");
+ addSystemInclude(DriverArgs, CC1Args, P);
+ }
+ // Also add <sysroot>/usr/include/c++/v1 unless -nostdinc is used,
+ // to match the legacy behavior in CC1.
+ if (!DriverArgs.hasArg(options::OPT_nostdinc)) {
+ llvm::SmallString<128> P = Sysroot;
+ llvm::sys::path::append(P, "usr", "include", "c++", "v1");
+ addSystemInclude(DriverArgs, CC1Args, P);
+ }
break;
}
+
case ToolChain::CST_Libstdcxx:
- // FIXME: should we do something about it?
+ llvm::SmallString<128> UsrIncludeCxx = Sysroot;
+ llvm::sys::path::append(UsrIncludeCxx, "usr", "include", "c++");
+
+ llvm::Triple::ArchType arch = getTriple().getArch();
+ bool IsBaseFound = true;
+ switch (arch) {
+ default: break;
+
+ case llvm::Triple::ppc:
+ case llvm::Triple::ppc64:
+ IsBaseFound = AddGnuCPlusPlusIncludePaths(DriverArgs, CC1Args, UsrIncludeCxx,
+ "4.2.1",
+ "powerpc-apple-darwin10",
+ arch == llvm::Triple::ppc64 ? "ppc64" : "");
+ IsBaseFound |= AddGnuCPlusPlusIncludePaths(DriverArgs, CC1Args, UsrIncludeCxx,
+ "4.0.0", "powerpc-apple-darwin10",
+ arch == llvm::Triple::ppc64 ? "ppc64" : "");
+ break;
+
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
+ IsBaseFound = AddGnuCPlusPlusIncludePaths(DriverArgs, CC1Args, UsrIncludeCxx,
+ "4.2.1",
+ "i686-apple-darwin10",
+ arch == llvm::Triple::x86_64 ? "x86_64" : "");
+ IsBaseFound |= AddGnuCPlusPlusIncludePaths(DriverArgs, CC1Args, UsrIncludeCxx,
+ "4.0.0", "i686-apple-darwin8",
+ "");
+ break;
+
+ case llvm::Triple::arm:
+ case llvm::Triple::thumb:
+ IsBaseFound = AddGnuCPlusPlusIncludePaths(DriverArgs, CC1Args, UsrIncludeCxx,
+ "4.2.1",
+ "arm-apple-darwin10",
+ "v7");
+ IsBaseFound |= AddGnuCPlusPlusIncludePaths(DriverArgs, CC1Args, UsrIncludeCxx,
+ "4.2.1",
+ "arm-apple-darwin10",
+ "v6");
+ break;
+
+ case llvm::Triple::aarch64:
+ IsBaseFound = AddGnuCPlusPlusIncludePaths(DriverArgs, CC1Args, UsrIncludeCxx,
+ "4.2.1",
+ "arm64-apple-darwin10",
+ "");
+ break;
+ }
+
+ if (!IsBaseFound) {
+ getDriver().Diag(diag::warn_drv_libstdcxx_not_found);
+ }
+
break;
}
}
const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
+ void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args) const override;
+
void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const override;
llvm::opt::ArgStringList &CmdArgs,
StringRef Sanitizer,
bool shared = true) const;
+
+ bool AddGnuCPlusPlusIncludePaths(const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args,
+ llvm::SmallString<128> Base,
+ llvm::StringRef Version,
+ llvm::StringRef ArchDir,
+ llvm::StringRef BitDir) const;
};
} // end namespace toolchains
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:
// 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) {
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) {
}
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
--- /dev/null
+// General tests that the header search paths for libc++ detected by the driver
+// and passed to CC1 are correct on Darwin platforms.
+
+// Check without a sysroot and without headers alongside the installation
+// (no include path should be added, and no warning or error).
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-apple-darwin \
+// RUN: -stdlib=libc++ \
+// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin \
+// RUN: | FileCheck --check-prefix=CHECK-LIBCXX-NONE %s
+// CHECK-LIBCXX-NONE: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+
+// Check with only headers alongside the installation (those should be used,
+// but we should still add /usr/include/c++/v1 after to preserve legacy).
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-apple-darwin \
+// RUN: -stdlib=libc++ \
+// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \
+// RUN: | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain --check-prefix=CHECK-LIBCXX-TOOLCHAIN-1 %s
+// CHECK-LIBCXX-TOOLCHAIN-1: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-LIBCXX-TOOLCHAIN-1: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1"
+// CHECK-LIBCXX-TOOLCHAIN-1: "-internal-isystem" "/usr/include/c++/v1"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-apple-darwin \
+// RUN: -stdlib=libc++ \
+// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \
+// RUN: -isysroot %S/Inputs/basic_darwin_sdk_no_libcxx \
+// RUN: | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain --check-prefix=CHECK-LIBCXX-TOOLCHAIN-2 %s
+// CHECK-LIBCXX-TOOLCHAIN-2: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-LIBCXX-TOOLCHAIN-2: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1"
+
+// Check with both headers in the sysroot and headers alongside the installation
+// (the headers in <sysroot> should be added after the toolchain headers).
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-apple-darwin \
+// RUN: -stdlib=libc++ \
+// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr \
+// RUN: | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr \
+// RUN: -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \
+// RUN: --check-prefix=CHECK-LIBCXX-SYSROOT_AND_TOOLCHAIN-1 %s
+// CHECK-LIBCXX-SYSROOT_AND_TOOLCHAIN-1: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-LIBCXX-SYSROOT_AND_TOOLCHAIN-1: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1"
+// CHECK-LIBCXX-SYSROOT_AND_TOOLCHAIN-1: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1"
+
+// Make sure that using -nostdinc or -nostdlibinc will drop the non-toolchain
+// C++ library include paths (so all except <toolchain>/usr/bin/../include/c++/v1).
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-apple-darwin \
+// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr \
+// RUN: -nostdinc \
+// RUN: | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr \
+// RUN: -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \
+// RUN: --check-prefix=CHECK-LIBCXX-NOSTDINC %s
+// CHECK-LIBCXX-NOSTDINC: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-LIBCXX-NOSTDINC: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1"
+// CHECK-LIBCXX-NOSTDINC-NOT: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-apple-darwin \
+// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr \
+// RUN: -nostdinc \
+// RUN: | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr \
+// RUN: -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \
+// RUN: --check-prefix=CHECK-LIBCXX-NOSTDLIBINC %s
+// CHECK-LIBCXX-NOSTDLIBINC: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-LIBCXX-NOSTDLIBINC: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1"
+// CHECK-LIBCXX-NOSTDLIBINC-NOT: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1"
--- /dev/null
+// General tests that the header search paths for libstdc++ detected by the
+// driver and passed to CC1 are correct on Darwin platforms.
+
+// Check ppc and ppc64
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target ppc-apple-darwin \
+// RUN: -stdlib=libstdc++ \
+// RUN: -isysroot %S/Inputs/basic_darwin_sdk_libstdcxx_ppc \
+// RUN: | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_libstdcxx_ppc --check-prefix=CHECK-LIBSTDCXX-PPC %s
+// CHECK-LIBSTDCXX-PPC: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-LIBSTDCXX-PPC: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1
+// CHECK-LIBSTDCXX-PPC: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1/powerpc-apple-darwin10"
+// CHECK-LIBSTDCXX-PPC: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1/backward"
+// CHECK-LIBSTDCXX-PPC: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.0.0"
+// CHECK-LIBSTDCXX-PPC: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.0.0/powerpc-apple-darwin10"
+// CHECK-LIBSTDCXX-PPC: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.0.0/backward"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target ppc64-apple-darwin \
+// RUN: -stdlib=libstdc++ \
+// RUN: -isysroot %S/Inputs/basic_darwin_sdk_libstdcxx_ppc \
+// RUN: | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_libstdcxx_ppc --check-prefix=CHECK-LIBSTDCXX-PPC64 %s
+// CHECK-LIBSTDCXX-PPC64: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-LIBSTDCXX-PPC64: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1"
+// CHECK-LIBSTDCXX-PPC64: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1/powerpc-apple-darwin10/ppc64"
+// CHECK-LIBSTDCXX-PPC64: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1/backward"
+// CHECK-LIBSTDCXX-PPC64: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.0.0"
+// CHECK-LIBSTDCXX-PPC64: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.0.0/powerpc-apple-darwin10/ppc64"
+// CHECK-LIBSTDCXX-PPC64: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.0.0/backward"
+
+// Check x86 and x86_64
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target i686-apple-darwin \
+// RUN: -stdlib=libstdc++ \
+// RUN: -isysroot %S/Inputs/basic_darwin_sdk_libstdcxx_x86 \
+// RUN: | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_libstdcxx_x86 --check-prefix=CHECK-LIBSTDCXX-X86 %s
+// CHECK-LIBSTDCXX-X86: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-LIBSTDCXX-X86: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1"
+// CHECK-LIBSTDCXX-X86: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1/i686-apple-darwin10"
+// CHECK-LIBSTDCXX-X86: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1/backward"
+// CHECK-LIBSTDCXX-X86: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.0.0"
+// CHECK-LIBSTDCXX-X86: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.0.0/i686-apple-darwin8"
+// CHECK-LIBSTDCXX-X86: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.0.0/backward"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-apple-darwin \
+// RUN: -stdlib=libstdc++ \
+// RUN: -isysroot %S/Inputs/basic_darwin_sdk_libstdcxx_x86 \
+// RUN: | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_libstdcxx_x86 --check-prefix=CHECK-LIBSTDCXX-X86_64 %s
+// CHECK-LIBSTDCXX-X86_64: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-LIBSTDCXX-X86_64: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1"
+// CHECK-LIBSTDCXX-X86_64: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1/i686-apple-darwin10/x86_64"
+// CHECK-LIBSTDCXX-X86_64: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1/backward"
+// CHECK-LIBSTDCXX-X86_64: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.0.0"
+// CHECK-LIBSTDCXX-X86_64: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.0.0/i686-apple-darwin8"
+// CHECK-LIBSTDCXX-X86_64: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.0.0/backward"
+
+// Check arm and thumb
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target arm-apple-darwin \
+// RUN: -stdlib=libstdc++ \
+// RUN: -isysroot %S/Inputs/basic_darwin_sdk_libstdcxx_arm \
+// RUN: | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_libstdcxx_arm --check-prefix=CHECK-LIBSTDCXX-ARM %s
+// CHECK-LIBSTDCXX-ARM: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-LIBSTDCXX-ARM: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1"
+// CHECK-LIBSTDCXX-ARM: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1/arm-apple-darwin10/v7"
+// CHECK-LIBSTDCXX-ARM: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1/backward"
+// CHECK-LIBSTDCXX-ARM: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1"
+// CHECK-LIBSTDCXX-ARM: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1/arm-apple-darwin10/v6"
+// CHECK-LIBSTDCXX-ARM: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1/backward"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target arm-apple-darwin \
+// RUN: -stdlib=libstdc++ \
+// RUN: -isysroot %S/Inputs/basic_darwin_sdk_libstdcxx_arm \
+// RUN: | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_libstdcxx_arm --check-prefix=CHECK-LIBSTDCXX-THUMB %s
+// CHECK-LIBSTDCXX-THUMB: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-LIBSTDCXX-THUMB: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1"
+// CHECK-LIBSTDCXX-THUMB: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1/arm-apple-darwin10/v7"
+// CHECK-LIBSTDCXX-THUMB: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1/backward"
+// CHECK-LIBSTDCXX-THUMB: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1"
+// CHECK-LIBSTDCXX-THUMB: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1/arm-apple-darwin10/v6"
+// CHECK-LIBSTDCXX-THUMB: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1/backward"
+
+// Check aarch64
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target arm64-apple-darwin \
+// RUN: -stdlib=libstdc++ \
+// RUN: -isysroot %S/Inputs/basic_darwin_sdk_libstdcxx_aarch64 \
+// RUN: | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_libstdcxx_aarch64 --check-prefix=CHECK-LIBSTDCXX-AARCH64 %s
+// CHECK-LIBSTDCXX-AARCH64: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-LIBSTDCXX-AARCH64: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1"
+// CHECK-LIBSTDCXX-AARCH64: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1/arm64-apple-darwin10"
+// CHECK-LIBSTDCXX-AARCH64: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1/backward"
+
+// Make sure we issue a warning when we can't find the path
+//
+// RUN: %clang -no-canonical-prefixes %s -fsyntax-only 2>&1 \
+// RUN: -target x86_64-apple-darwin \
+// RUN: -stdlib=libstdc++ \
+// RUN: -isysroot %S/Inputs/basic_darwin_sdk_no_libstdcxx \
+// RUN: | FileCheck --check-prefix=CHECK-LIBSTDCXX-MISSING %s
+// CHECK-LIBSTDCXX-MISSING: clang: warning: include path for libstdc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead
+//
+// RUN: %clang %s -target x86_64-apple-darwin -fsyntax-only 2>&1 \
+// RUN: -isysroot %S/Inputs/basic_darwin_sdk_no_libstdcxx \
+// RUN: -stdlib=libc++ \
+// RUN: | FileCheck -allow-empty --check-prefix=CHECK-LIBSTDCXX-MISSING-1 %s
+// CHECK-LIBSTDCXX-MISSING-1-NOT: warning
+//
+// RUN: %clang %s -target x86_64-apple-darwin -fsyntax-only 2>&1 \
+// RUN: -isysroot %S/Inputs/basic_darwin_sdk_no_libstdcxx \
+// RUN: | FileCheck -allow-empty --check-prefix=CHECK-LIBSTDCXX-MISSING-2 %s
+// CHECK-LIBSTDCXX-MISSING-2-NOT: warning
--- /dev/null
+// General tests that the system header search paths detected by the driver
+// and passed to CC1 are correct on Darwin platforms.
+
+// Check system headers (everything below <sysroot> and <resource-dir>)
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-apple-darwin \
+// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr_and_usr_local \
+// RUN: | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr_and_usr_local \
+// RUN: -DRESOURCE=%S/Inputs/resource_dir \
+// RUN: --check-prefix=CHECK-SYSTEM %s
+// CHECK-SYSTEM: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-SYSTEM: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-SYSTEM: "-internal-isystem" "[[RESOURCE]]/include"
+// CHECK-SYSTEM: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+
+// Make sure that using -nobuiltininc will drop resource headers
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-apple-darwin \
+// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr_and_usr_local \
+// RUN: -nobuiltininc \
+// RUN: | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr_and_usr_local \
+// RUN: -DRESOURCE=%S/Inputs/resource_dir \
+// RUN: --check-prefix=CHECK-NOBUILTININC %s
+// CHECK-NOBUILTININC: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-NOBUILTININC: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-NOBUILTININC-NOT: "-internal-isystem" "[[RESOURCE]]/include"
+// CHECK-NOBUILTININC: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+
+// Make sure that using -nostdlibinc will drop <sysroot>/usr/local/include and
+// <sysroot>/usr/include.
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-apple-darwin \
+// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr_and_usr_local \
+// RUN: -nostdlibinc \
+// RUN: | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr_and_usr_local \
+// RUN: -DRESOURCE=%S/Inputs/resource_dir \
+// RUN: --check-prefix=CHECK-NOSTDLIBINC %s
+// CHECK-NOSTDLIBINC: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-NOSTDLIBINC-NOT: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-NOSTDLIBINC: "-internal-isystem" "[[RESOURCE]]/include"
+// CHECK-NOSTDLIBINC-NOT: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+
+// Make sure that -nostdinc drops all the system include paths, including
+// <resource>/include.
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-apple-darwin \
+// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr_and_usr_local \
+// RUN: -nostdinc \
+// RUN: | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr_and_usr_local \
+// RUN: -DRESOURCE=%S/Inputs/resource_dir \
+// RUN: --check-prefix=CHECK-NOSTDINC %s
+// CHECK-NOSTDINC: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-NOSTDINC-NOT: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-NOSTDINC-NOT: "-internal-isystem" "[[RESOURCE]]/include"
+// CHECK-NOSTDINC-NOT: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+
+// Check search paths without -isysroot
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-apple-darwin \
+// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: | FileCheck -DRESOURCE=%S/Inputs/resource_dir \
+// RUN: --check-prefix=CHECK-NOSYSROOT %s
+// CHECK-NOSYSROOT: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-NOSYSROOT: "-internal-isystem" "/usr/local/include"
+// CHECK-NOSYSROOT: "-internal-isystem" "[[RESOURCE]]/include"
+// CHECK-NOSYSROOT: "-internal-externc-isystem" "/usr/include"
// XFAIL: default-cxx-stdlib-set
// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch arm64 -miphoneos-version-min=7.0 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBCXX
-// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -mmacosx-version-min=10.8 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBSTDCXX
+// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -mmacosx-version-min=10.8 -Wno-stdlibcxx-not-found %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBSTDCXX
// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -mmacosx-version-min=10.9 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBCXX
-// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch armv7s -miphoneos-version-min=6.1 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBSTDCXX
+// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch armv7s -miphoneos-version-min=6.1 -Wno-stdlibcxx-not-found %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBSTDCXX
// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch armv7s -miphoneos-version-min=7.0 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBCXX
// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch armv7k %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBCXX
-// The purpose of this test is that the libc++ headers should be found
-// properly. We also pass -stdlib=libc++ to make sure the logic to add the
-// optional absolute include for libc++ from InitHeaderSearch.cpp also fires.
-
// CHECK-LIBCXX: "-stdlib=libc++"
-// CHECK-LIBCXX: "-internal-isystem" "{{[^"]*}}{{/|\\\\}}Inputs{{/|\\\\}}darwin_toolchain_tree{{/|\\\\}}bin{{/|\\\\}}..{{/|\\\\}}include{{/|\\\\}}c++{{/|\\\\}}v1"
-
// CHECK-LIBSTDCXX-NOT: -stdlib=libc++
// CHECK-LIBSTDCXX-NOT: -stdlib=libstdc++
-// CHECK-LIBSTDCXX-NOT: -internal-isystem
+++ /dev/null
-// RUN: %clang -cc1 -triple arm64-apple-ios6.0.0 -isysroot %S/doesnotexist %s 2>&1 | FileCheck %s
-// RUN: %clang -cc1 -triple arm64-apple-ios6.0.0 -isysroot %S/doesnotexist -stdlib=libc++ %s -verify
-// RUN: %clang -cc1 -x c++-cpp-output -triple arm64-apple-ios6.0.0 -isysroot %S/doesnotexist %s -verify
-// CHECK: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead
-
-// expected-no-diagnostics