]> granicus.if.org Git - clang/commitdiff
Add another workaround for -include.
authorDaniel Dunbar <daniel@zuster.org>
Wed, 22 Apr 2009 08:53:01 +0000 (08:53 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Wed, 22 Apr 2009 08:53:01 +0000 (08:53 +0000)
 - 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69794 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/InitPreprocessor.cpp

index 746eba9cf2b6a1ef958d3bfe9956771736028dca..f9929d1558a6f5c095695ef6cd12c8dc9b3514a7 100644 (file)
@@ -54,11 +54,17 @@ static void DefineBuiltinMacro(std::vector<char> &Buf, const char *Macro,
 /// 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);
   Path.makeAbsolute();
+  if (!Path.exists())
+    Path = File;
     
   // Escape double quotes etc.
   Buf.push_back('"');