summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-04-22 08:53:01 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-04-22 08:53:01 +0000
commit66cb01313b5fb5f6e667b02a2a1f1a0a1f9ddf35 (patch)
treefd97c93bba6e37b95a1370ab2fadd8f32bd045e9 /clang/lib
parent83a66f78d28aebc015750fc7166235788298c617 (diff)
downloadbcm5719-llvm-66cb01313b5fb5f6e667b02a2a1f1a0a1f9ddf35.tar.gz
bcm5719-llvm-66cb01313b5fb5f6e667b02a2a1f1a0a1f9ddf35.zip
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. llvm-svn: 69794
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Frontend/InitPreprocessor.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp
index 746eba9cf2b..f9929d1558a 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -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('"');
OpenPOWER on IntegriCloud