summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2016-05-06 19:13:55 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2016-05-06 19:13:55 +0000
commitde87e5f87565b78706e0d0289632ea8ccba4f211 (patch)
treeecbf57843b82e377b99a7646bb4c986d71cf9417 /clang/lib/Frontend/CompilerInvocation.cpp
parentadb7ff02831dbf398bdf60f404da43d1818a486f (diff)
downloadbcm5719-llvm-de87e5f87565b78706e0d0289632ea8ccba4f211.tar.gz
bcm5719-llvm-de87e5f87565b78706e0d0289632ea8ccba4f211.zip
Frontend: support -I=path for sysroot expansion
From the GCC manpage: -I dir ... If dir begins with =, then the = will be replaced by the sysroot prefix; see --sysroot and -isysroot. Add support to expand the `=` as a prefix of the include path with the sysroot if specified. `-isysroot` takes precedence over `--sysroot` as the normal argument behaviour occurs. The ordering of the `-isysroot` is relevant to the path substituted. If no `--sysroot=` or `-isysroot` option is present, the = is not expanded. Resolves PR26965! llvm-svn: 268777
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 0b154b6743c..a97dc92adfa 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1278,6 +1278,8 @@ static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args) {
// Add -I..., -F..., and -index-header-map options in order.
bool IsIndexHeaderMap = false;
+ bool IsSysrootSpecified =
+ Args.hasArg(OPT__sysroot_EQ) || Args.hasArg(OPT_isysroot);
for (const Arg *A : Args.filtered(OPT_I, OPT_F, OPT_index_header_map)) {
if (A->getOption().matches(OPT_index_header_map)) {
// -index-header-map applies to the next -I or -F.
@@ -1288,8 +1290,18 @@ static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args) {
frontend::IncludeDirGroup Group =
IsIndexHeaderMap ? frontend::IndexHeaderMap : frontend::Angled;
- Opts.AddPath(A->getValue(), Group,
- /*IsFramework=*/A->getOption().matches(OPT_F), true);
+ bool IsFramework = A->getOption().matches(OPT_F);
+ std::string Path = A->getValue();
+
+ if (IsSysrootSpecified && !IsFramework && A->getValue()[0] == '=') {
+ SmallString<32> Buffer;
+ llvm::sys::path::append(Buffer, Opts.Sysroot,
+ llvm::StringRef(A->getValue()).substr(1));
+ Path = Buffer.str();
+ }
+
+ Opts.AddPath(Path.c_str(), Group, IsFramework,
+ /*IgnoreSysroot*/ true);
IsIndexHeaderMap = false;
}
OpenPOWER on IntegriCloud