[cfe-commits] r69794 - /cfe/trunk/lib/Frontend/InitPreprocessor.cpp

Daniel Dunbar daniel at zuster.org
Wed Apr 22 01:53:02 PDT 2009

Author: ddunbar
Date: Wed Apr 22 03:53:01 2009
New Revision: 69794

URL: http://llvm.org/viewvc/llvm-project?rev=69794&view=rev
Add another workaround for -include.
 - If we don't find a file looking relative to the current working
   directory, fall back to header search. This is closer to what would
   happen if the lookup was starting from right directory in the first
   place (except it will find files in the directory of the main
   source file, which I *think* should not be found).

 - PR3992.


Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=69794&r1=69793&r2=69794&view=diff

--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Wed Apr 22 03:53:01 2009
@@ -54,11 +54,17 @@
 /// Add the quoted name of an implicit include file.
 static void AddQuotedIncludePath(std::vector<char> &Buf, 
                                  const std::string &File) {
-  // Implicit include paths are relative to the current working
-  // directory; resolve them now instead of using the normal machinery
-  // (which would look relative to the input file).
+  // Implicit include paths should be resolved relative to the current
+  // working directory first, and then use the regular header search
+  // mechanism. The proper way to handle this is to have the
+  // predefines buffer located at the current working directory, but
+  // it has not file entry. For now, workaround this by using an
+  // absolute path if we find the file here, and otherwise letting
+  // header search handle it.
   llvm::sys::Path Path(File);
+  if (!Path.exists())
+    Path = File;
   // Escape double quotes etc.

More information about the cfe-commits mailing list