[clang] 6fa3894 - [clang] Fix search path logic for C_INCLUDE_DIRS
Louis Dionne via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 20 09:48:51 PST 2020
Author: Louis Dionne
Date: 2020-02-20T12:35:15-05:00
New Revision: 6fa3894c4e771c773712b1ae777f78c1c922a908
URL: https://github.com/llvm/llvm-project/commit/6fa3894c4e771c773712b1ae777f78c1c922a908
DIFF: https://github.com/llvm/llvm-project/commit/6fa3894c4e771c773712b1ae777f78c1c922a908.diff
LOG: [clang] Fix search path logic for C_INCLUDE_DIRS
For each absolute path given to C_INCLUDE_DIRS, we want it to be added
as-is to the include search path. Relative paths should be prefixed
with the sysroot.
Thanks to Marco Hinz for the patch.
Differential Revision: https://reviews.llvm.org/D69221
Added:
Modified:
clang/lib/Driver/ToolChains/Darwin.cpp
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/lib/Driver/ToolChains/Hurd.cpp
clang/lib/Driver/ToolChains/Linux.cpp
clang/lib/Driver/ToolChains/Solaris.cpp
clang/lib/Driver/ToolChains/WebAssembly.cpp
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp
index 97f7905685c1..b32fad791bd3 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1899,7 +1899,7 @@ void DarwinClang::AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs
CIncludeDirs.split(dirs, ":");
for (llvm::StringRef dir : dirs) {
llvm::StringRef Prefix =
- llvm::sys::path::is_absolute(dir) ? llvm::StringRef(Sysroot) : "";
+ llvm::sys::path::is_absolute(dir) ? "" : llvm::StringRef(Sysroot);
addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
}
} else {
diff --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 6114829ac8e1..fbda60ac7a45 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -289,7 +289,7 @@ void Fuchsia::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
CIncludeDirs.split(dirs, ":");
for (StringRef dir : dirs) {
StringRef Prefix =
- llvm::sys::path::is_absolute(dir) ? StringRef(D.SysRoot) : "";
+ llvm::sys::path::is_absolute(dir) ? "" : StringRef(D.SysRoot);
addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
}
return;
diff --git a/clang/lib/Driver/ToolChains/Hurd.cpp b/clang/lib/Driver/ToolChains/Hurd.cpp
index 51d9c28244ab..72286bd09f13 100644
--- a/clang/lib/Driver/ToolChains/Hurd.cpp
+++ b/clang/lib/Driver/ToolChains/Hurd.cpp
@@ -149,7 +149,7 @@ void Hurd::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
CIncludeDirs.split(Dirs, ":");
for (StringRef Dir : Dirs) {
StringRef Prefix =
- llvm::sys::path::is_absolute(Dir) ? StringRef(SysRoot) : "";
+ llvm::sys::path::is_absolute(Dir) ? "" : StringRef(SysRoot);
addExternCSystemInclude(DriverArgs, CC1Args, Prefix + Dir);
}
return;
diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
index c86023ef7d91..d8d8a8da8fca 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -676,7 +676,7 @@ void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
CIncludeDirs.split(dirs, ":");
for (StringRef dir : dirs) {
StringRef Prefix =
- llvm::sys::path::is_absolute(dir) ? StringRef(SysRoot) : "";
+ llvm::sys::path::is_absolute(dir) ? "" : StringRef(SysRoot);
addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
}
return;
diff --git a/clang/lib/Driver/ToolChains/Solaris.cpp b/clang/lib/Driver/ToolChains/Solaris.cpp
index fc4e2cf151ef..0a1ac0b22586 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -244,7 +244,7 @@ void Solaris::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
CIncludeDirs.split(dirs, ":");
for (StringRef dir : dirs) {
StringRef Prefix =
- llvm::sys::path::is_absolute(dir) ? StringRef(D.SysRoot) : "";
+ llvm::sys::path::is_absolute(dir) ? "" : StringRef(D.SysRoot);
addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
}
return;
diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index adf8eb077201..461ec75d17f6 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -283,7 +283,7 @@ void WebAssembly::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
CIncludeDirs.split(dirs, ":");
for (StringRef dir : dirs) {
StringRef Prefix =
- llvm::sys::path::is_absolute(dir) ? StringRef(D.SysRoot) : "";
+ llvm::sys::path::is_absolute(dir) ? "" : StringRef(D.SysRoot);
addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
}
return;
More information about the cfe-commits
mailing list