[cfe-commits] r167114 - in /cfe/trunk: lib/Driver/Driver.cpp test/Driver/B-opt.c test/Driver/Inputs/B_opt_tree/ test/Driver/Inputs/B_opt_tree/dir1/ test/Driver/Inputs/B_opt_tree/dir1/i386-unknown-linux-ld test/Driver/Inputs/B_opt_tree/dir1/ld test/Driver/Inputs/B_opt_tree/dir2/ test/Driver/Inputs/B_opt_tree/dir2/ld test/Driver/Inputs/B_opt_tree/dir3/ test/Driver/Inputs/B_opt_tree/dir3/prefix-ld

Simon Atanasyan satanasyan at mips.com
Wed Oct 31 05:01:53 PDT 2012


Author: atanasyan
Date: Wed Oct 31 07:01:53 2012
New Revision: 167114

URL: http://llvm.org/viewvc/llvm-project?rev=167114&view=rev
Log:
Extend -Bprefix functionality and make it closer to gcc. If the "prefix"
is not a directory, Driver::GetProgramPath() routine does not try to append
the program name as a "path component" to it. It just joins the "prefix" with
the program name and checks the resulting path existence.

The patch reviewed by Rafael Espindola.

Added:
    cfe/trunk/test/Driver/B-opt.c
    cfe/trunk/test/Driver/Inputs/B_opt_tree/
    cfe/trunk/test/Driver/Inputs/B_opt_tree/dir1/
    cfe/trunk/test/Driver/Inputs/B_opt_tree/dir1/i386-unknown-linux-ld   (with props)
    cfe/trunk/test/Driver/Inputs/B_opt_tree/dir1/ld   (with props)
    cfe/trunk/test/Driver/Inputs/B_opt_tree/dir2/
    cfe/trunk/test/Driver/Inputs/B_opt_tree/dir2/ld   (with props)
    cfe/trunk/test/Driver/Inputs/B_opt_tree/dir3/
    cfe/trunk/test/Driver/Inputs/B_opt_tree/dir3/prefix-ld   (with props)
Modified:
    cfe/trunk/lib/Driver/Driver.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=167114&r1=167113&r2=167114&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Wed Oct 31 07:01:53 2012
@@ -1591,12 +1591,19 @@
   // attempting to use this prefix when looking for program paths.
   for (Driver::prefix_list::const_iterator it = PrefixDirs.begin(),
        ie = PrefixDirs.end(); it != ie; ++it) {
-    llvm::sys::Path P(*it);
-    P.appendComponent(TargetSpecificExecutable);
-    if (P.canExecute()) return P.str();
-    P.eraseComponent();
-    P.appendComponent(Name);
-    if (P.canExecute()) return P.str();
+    bool IsDirectory;
+    if (!llvm::sys::fs::is_directory(*it, IsDirectory) && IsDirectory) {
+      llvm::sys::Path P(*it);
+      P.appendComponent(TargetSpecificExecutable);
+      if (P.canExecute()) return P.str();
+      P.eraseComponent();
+      P.appendComponent(Name);
+      if (P.canExecute()) return P.str();
+    }
+    else {
+      llvm::sys::Path P(*it + Name);
+      if (P.canExecute()) return P.str();
+    }
   }
 
   const ToolChain::path_list &List = TC.getProgramPaths();

Added: cfe/trunk/test/Driver/B-opt.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/B-opt.c?rev=167114&view=auto
==============================================================================
--- cfe/trunk/test/Driver/B-opt.c (added)
+++ cfe/trunk/test/Driver/B-opt.c Wed Oct 31 07:01:53 2012
@@ -0,0 +1,22 @@
+// Check -B driver option.
+//
+// RUN: %clang %s -### -o %t.o -target i386-unknown-linux \
+// RUN:     -B %S/Inputs/B_opt_tree/dir1 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-B-OPT-TRIPLE %s
+// CHECK-B-OPT-TRIPLE: "{{.*}}/Inputs/B_opt_tree/dir1/i386-unknown-linux-ld"
+//
+// RUN: %clang %s -### -o %t.o -target i386-unknown-linux \
+// RUN:     -B %S/Inputs/B_opt_tree/dir2 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-B-OPT-DIR %s
+// CHECK-B-OPT-DIR: "{{.*}}/Inputs/B_opt_tree/dir2/ld"
+//
+// RUN: %clang %s -### -o %t.o -target i386-unknown-linux \
+// RUN:     -B %S/Inputs/B_opt_tree/dir3/prefix- 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-B-OPT-PREFIX %s
+// CHECK-B-OPT-PREFIX: "{{.*}}/Inputs/B_opt_tree/dir3/prefix-ld"
+//
+// RUN: %clang %s -### -o %t.o -target i386-unknown-linux \
+// RUN:     -B %S/Inputs/B_opt_tree/dir3/prefix- \
+// RUN:     -B %S/Inputs/B_opt_tree/dir2 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-B-OPT-MULT %s
+// CHECK-B-OPT-MULT: "{{.*}}/Inputs/B_opt_tree/dir3/prefix-ld"

Added: cfe/trunk/test/Driver/Inputs/B_opt_tree/dir1/i386-unknown-linux-ld
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/B_opt_tree/dir1/i386-unknown-linux-ld?rev=167114&view=auto
==============================================================================
    (empty)

Propchange: cfe/trunk/test/Driver/Inputs/B_opt_tree/dir1/i386-unknown-linux-ld
------------------------------------------------------------------------------
    svn:executable = *

Added: cfe/trunk/test/Driver/Inputs/B_opt_tree/dir1/ld
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/B_opt_tree/dir1/ld?rev=167114&view=auto
==============================================================================
    (empty)

Propchange: cfe/trunk/test/Driver/Inputs/B_opt_tree/dir1/ld
------------------------------------------------------------------------------
    svn:executable = *

Added: cfe/trunk/test/Driver/Inputs/B_opt_tree/dir2/ld
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/B_opt_tree/dir2/ld?rev=167114&view=auto
==============================================================================
    (empty)

Propchange: cfe/trunk/test/Driver/Inputs/B_opt_tree/dir2/ld
------------------------------------------------------------------------------
    svn:executable = *

Added: cfe/trunk/test/Driver/Inputs/B_opt_tree/dir3/prefix-ld
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/B_opt_tree/dir3/prefix-ld?rev=167114&view=auto
==============================================================================
    (empty)

Propchange: cfe/trunk/test/Driver/Inputs/B_opt_tree/dir3/prefix-ld
------------------------------------------------------------------------------
    svn:executable = *





More information about the cfe-commits mailing list