[PATCH] PR21174 - clang only searches current working directory for precompiled include file

Nikola Smiljanić popizdeh at gmail.com
Tue Jun 30 19:08:11 PDT 2015


Added test.


http://reviews.llvm.org/D10431

Files:
  lib/Driver/Tools.cpp
  test/PCH/additional-include.cpp
  test/PCH/additional-include.h

Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -387,6 +387,16 @@
         if (llvm::sys::fs::exists(P)) {
           FoundPCH = UsePCH;
           FoundPTH = !UsePCH;
+        } else {
+          for (const Arg *A : Args.filtered(options::OPT_I_Group)) {
+            SmallString<128> Path(A->getValue());
+            llvm::sys::path::append(Path, P);
+            if (llvm::sys::fs::exists(Path)) {
+              P = Path;
+              FoundPCH = UsePCH;
+              FoundPTH = !UsePCH;
+            }
+          }
         }
       }
 
Index: test/PCH/additional-include.cpp
===================================================================
--- /dev/null
+++ test/PCH/additional-include.cpp
@@ -0,0 +1,9 @@
+// RUN: mkdir -p %t.h.gch
+// RUN: %clang -x c++-header %S/additional-include.h -o %t.h.gch/additional-include.h.gch 
+// RUN: %clang -x c++ -include additional-include.h -I %t.h.gch -fsyntax-only %s -Xclang -print-stats 2> %t.log
+// RUN: FileCheck %s < %t.log
+
+int foo() {
+  // CHECK: .h.gch{{[/\\]}}additional-include.h.gch
+  return i;
+}
Index: test/PCH/additional-include.h
===================================================================
--- /dev/null
+++ test/PCH/additional-include.h
@@ -0,0 +1,2 @@
+
+extern int i;

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10431.28838.patch
Type: text/x-patch
Size: 1353 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150701/373c463e/attachment.bin>


More information about the cfe-commits mailing list