[PATCH] D32952: Follow up patch for D31495

Yuka Takahashi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 7 02:03:34 PDT 2017


yamaguchi updated this revision to Diff 98093.
yamaguchi added a comment.

Add comment to code.


https://reviews.llvm.org/D32952

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/sysroot-flags.c


Index: clang/test/Driver/sysroot-flags.c
===================================================================
--- clang/test/Driver/sysroot-flags.c
+++ clang/test/Driver/sysroot-flags.c
@@ -26,3 +26,7 @@
 // RUN:   FileCheck %s -check-prefix=SYSROOT_SEPARATE
 // SYSROOT_SEPARATE: "-isysroot" "{{[^"]*}}/foo/bar"
 // SYSROOT_SEPARATE: "--sysroot{{" "|=}}{{[^"]*}}/foo/bar"
+
+// Check that -isysroot is handled properly
+// RUN: %clang -isysroot /foo/bar -c %s -v 2>&1 | \
+// RUN:   grep "/foo/bar"
Index: clang/lib/Frontend/CompilerInvocation.cpp
===================================================================
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1566,7 +1566,16 @@
     frontend::IncludeDirGroup Group = frontend::System;
     if (A->getOption().matches(OPT_internal_externc_isystem))
       Group = frontend::ExternCSystem;
-    Opts.AddPath(A->getValue(), Group, false, true);
+
+    // Check if the path is a builtin header or not.
+    // If the path is a builtin header, IgnoreSysRoot is true because otherwise it puts isystem prefix to builtin headers. 
+    SmallString<128> P(Opts.ResourceDir);
+    llvm::sys::path::append(P, "include");
+
+    if (StringRef(A->getValue()) == P)
+      Opts.AddPath(A->getValue(), Group, false, true);
+    else
+      Opts.AddPath(A->getValue(), Group, false, false);
   }
 
   // Add the path prefixes which are implicitly treated as being system headers.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32952.98093.patch
Type: text/x-patch
Size: 1467 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170507/d59e40d4/attachment.bin>


More information about the llvm-commits mailing list