]> granicus.if.org Git - clang/commitdiff
Add the resource directory to the search path for Driver::GetFilePath,
authorPeter Collingbourne <peter@pcc.me.uk>
Tue, 6 Sep 2011 02:08:31 +0000 (02:08 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Tue, 6 Sep 2011 02:08:31 +0000 (02:08 +0000)
as well as the search path printed by -print-search-dirs.

The main purpose of this change is to cause -print-file-name=include
to print the path to the include directory under Clang's resource
directory, instead of the system compiler's include directory, whose
header files Clang may not be able to parse.  Some build scripts will
do something like:
  $(CC) -nostdinc -I`$(CC) -print-file-name=include`
to exclude all header paths except the compiler's.

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

lib/Driver/Driver.cpp

index 534984b4b3a7e8b33ff00cfe5b7071a31f663fff..bb018595882896f27941682d295dd56878c236e3 100644 (file)
@@ -585,7 +585,7 @@ bool Driver::HandleImmediateArgs(const Compilation &C) {
       llvm::outs() << *it;
     }
     llvm::outs() << "\n";
-    llvm::outs() << "libraries: =";
+    llvm::outs() << "libraries: =" << ResourceDir;
 
     std::string sysroot;
     if (Arg *A = C.getArgs().getLastArg(options::OPT__sysroot_EQ))
@@ -593,8 +593,7 @@ bool Driver::HandleImmediateArgs(const Compilation &C) {
 
     for (ToolChain::path_list::const_iterator it = TC.getFilePaths().begin(),
            ie = TC.getFilePaths().end(); it != ie; ++it) {
-      if (it != TC.getFilePaths().begin())
-        llvm::outs() << ':';
+      llvm::outs() << ':';
       const char *path = it->c_str();
       if (path[0] == '=')
         llvm::outs() << sysroot << path + 1;
@@ -1428,6 +1427,12 @@ std::string Driver::GetFilePath(const char *Name, const ToolChain &TC) const {
       return P.str();
   }
 
+  llvm::sys::Path P(ResourceDir);
+  P.appendComponent(Name);
+  bool Exists;
+  if (!llvm::sys::fs::exists(P.str(), Exists) && Exists)
+    return P.str();
+
   const ToolChain::path_list &List = TC.getFilePaths();
   for (ToolChain::path_list::const_iterator
          it = List.begin(), ie = List.end(); it != ie; ++it) {