summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/ToolChains.cpp
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2015-11-09 21:10:54 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2015-11-09 21:10:54 +0000
commit65bc2b12233248f086461bea4d57bd2920c624c8 (patch)
tree7c87b45d47e31584970c00cf378d4878e384d8cf /clang/lib/Driver/ToolChains.cpp
parent9d851f043527f36195d276f4ddf78b3b4e399709 (diff)
downloadbcm5719-llvm-65bc2b12233248f086461bea4d57bd2920c624c8.tar.gz
bcm5719-llvm-65bc2b12233248f086461bea4d57bd2920c624c8.zip
Extend linux header search to find libc++ headers in c++/vN for any N.
llvm-svn: 252514
Diffstat (limited to 'clang/lib/Driver/ToolChains.cpp')
-rw-r--r--clang/lib/Driver/ToolChains.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/clang/lib/Driver/ToolChains.cpp b/clang/lib/Driver/ToolChains.cpp
index d39bfaa4bec..5df96ce54e3 100644
--- a/clang/lib/Driver/ToolChains.cpp
+++ b/clang/lib/Driver/ToolChains.cpp
@@ -3849,6 +3849,25 @@ void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
}
+static std::string DetectLibcxxIncludePath(StringRef base) {
+ std::error_code EC;
+ int MaxVersion = 0;
+ std::string MaxVersionString = "";
+ for (llvm::sys::fs::directory_iterator LI(base, EC), LE; !EC && LI != LE;
+ LI = LI.increment(EC)) {
+ StringRef VersionText = llvm::sys::path::filename(LI->path());
+ int Version;
+ if (VersionText[0] == 'v' &&
+ !VersionText.slice(1, StringRef::npos).getAsInteger(10, Version)) {
+ if (Version > MaxVersion) {
+ MaxVersion = Version;
+ MaxVersionString = VersionText;
+ }
+ }
+ }
+ return MaxVersion ? (base + "/" + MaxVersionString).str() : "";
+}
+
void Linux::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
@@ -3858,17 +3877,14 @@ void Linux::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
// Check if libc++ has been enabled and provide its include paths if so.
if (GetCXXStdlibType(DriverArgs) == ToolChain::CST_Libcxx) {
const std::string LibCXXIncludePathCandidates[] = {
- // The primary location is within the Clang installation.
- // FIXME: We shouldn't hard code 'v1' here to make Clang future proof to
- // newer ABI versions.
- getDriver().Dir + "/../include/c++/v1",
+ DetectLibcxxIncludePath(getDriver().Dir + "/../include/c++"),
// We also check the system as for a long time this is the only place
// Clang looked.
// FIXME: We should really remove this. It doesn't make any sense.
- getDriver().SysRoot + "/usr/include/c++/v1"};
+ DetectLibcxxIncludePath(getDriver().SysRoot + "/usr/include/c++")};
for (const auto &IncludePath : LibCXXIncludePathCandidates) {
- if (!getVFS().exists(IncludePath))
+ if (IncludePath.empty() || !getVFS().exists(IncludePath))
continue;
// Add the first candidate that exists.
addSystemInclude(DriverArgs, CC1Args, IncludePath);
OpenPOWER on IntegriCloud