Use the InstalledDir correctly, and test it correctly as well. =/ Should
have noticed this previously, sorry.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141167 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
index 0e9dcd1..eab76d5 100644
--- a/lib/Driver/ToolChains.cpp
+++ b/lib/Driver/ToolChains.cpp
@@ -1589,7 +1589,7 @@
                                          D.PrefixDirs.end());
     Prefixes.push_back(D.SysRoot);
     Prefixes.push_back(D.SysRoot + "/usr");
-    Prefixes.push_back(D.InstalledDir);
+    Prefixes.push_back(D.InstalledDir + "/..");
 
     // Loop over the various components which exist and select the best GCC
     // installation available. GCC installs are ranked by version number.
diff --git a/test/Driver/Inputs/fake_install_tree/bin/.keep b/test/Driver/Inputs/fake_install_tree/bin/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/fake_install_tree/bin/.keep
diff --git a/test/Driver/Inputs/gcc_version_parsing1/bin/.keep b/test/Driver/Inputs/gcc_version_parsing1/bin/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/gcc_version_parsing1/bin/.keep
diff --git a/test/Driver/Inputs/gcc_version_parsing2/bin/.keep b/test/Driver/Inputs/gcc_version_parsing2/bin/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/gcc_version_parsing2/bin/.keep
diff --git a/test/Driver/Inputs/gcc_version_parsing3/bin/.keep b/test/Driver/Inputs/gcc_version_parsing3/bin/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/gcc_version_parsing3/bin/.keep
diff --git a/test/Driver/linux-ld.c b/test/Driver/linux-ld.c
index a967183..46fbe7f 100644
--- a/test/Driver/linux-ld.c
+++ b/test/Driver/linux-ld.c
@@ -93,18 +93,18 @@
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     -ccc-host-triple i386-unknown-linux -m32 \
-// RUN:     -ccc-install-dir %S/Inputs/fake_install_tree \
+// RUN:     -ccc-install-dir %S/Inputs/fake_install_tree/bin \
 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-INSTALL-DIR-32 %s
 // CHECK-INSTALL-DIR-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
-// CHECK-INSTALL-DIR-32: "{{.*}}/Inputs/fake_install_tree/lib/gcc/i386-unknown-linux/4.7.0/crtbegin.o"
-// CHECK-INSTALL-DIR-32: "-L{{.*}}/Inputs/fake_install_tree/lib/gcc/i386-unknown-linux/4.7.0"
+// CHECK-INSTALL-DIR-32: "{{.*}}/Inputs/fake_install_tree/bin/../lib/gcc/i386-unknown-linux/4.7.0/crtbegin.o"
+// CHECK-INSTALL-DIR-32: "-L{{.*}}/Inputs/fake_install_tree/bin/../lib/gcc/i386-unknown-linux/4.7.0"
 //
 // Check that with 64-bit builds, we don't actually use the install directory
 // as its version of GCC is lower than our sysrooted version.
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     -ccc-host-triple x86_64-unknown-linux -m64 \
-// RUN:     -ccc-install-dir %S/Inputs/fake_install_tree \
+// RUN:     -ccc-install-dir %S/Inputs/fake_install_tree/bin \
 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-INSTALL-DIR-64 %s
 // CHECK-INSTALL-DIR-64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
@@ -115,25 +115,25 @@
 // component.
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     -ccc-host-triple i386-unknown-linux -m32 \
-// RUN:     -ccc-install-dir %S/Inputs/gcc_version_parsing1 \
+// RUN:     -ccc-install-dir %S/Inputs/gcc_version_parsing1/bin \
 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-GCC-VERSION1 %s
 // CHECK-GCC-VERSION1: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
-// CHECK-GCC-VERSION1: "{{.*}}/Inputs/gcc_version_parsing1/lib/gcc/i386-unknown-linux/4.7/crtbegin.o"
-// CHECK-GCC-VERSION1: "-L{{.*}}/Inputs/gcc_version_parsing1/lib/gcc/i386-unknown-linux/4.7"
+// CHECK-GCC-VERSION1: "{{.*}}/Inputs/gcc_version_parsing1/bin/../lib/gcc/i386-unknown-linux/4.7/crtbegin.o"
+// CHECK-GCC-VERSION1: "-L{{.*}}/Inputs/gcc_version_parsing1/bin/../lib/gcc/i386-unknown-linux/4.7"
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     -ccc-host-triple i386-unknown-linux -m32 \
-// RUN:     -ccc-install-dir %S/Inputs/gcc_version_parsing2 \
+// RUN:     -ccc-install-dir %S/Inputs/gcc_version_parsing2/bin \
 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-GCC-VERSION2 %s
 // CHECK-GCC-VERSION2: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
-// CHECK-GCC-VERSION2: "{{.*}}/Inputs/gcc_version_parsing2/lib/gcc/i386-unknown-linux/4.7.x/crtbegin.o"
-// CHECK-GCC-VERSION2: "-L{{.*}}/Inputs/gcc_version_parsing2/lib/gcc/i386-unknown-linux/4.7.x"
+// CHECK-GCC-VERSION2: "{{.*}}/Inputs/gcc_version_parsing2/bin/../lib/gcc/i386-unknown-linux/4.7.x/crtbegin.o"
+// CHECK-GCC-VERSION2: "-L{{.*}}/Inputs/gcc_version_parsing2/bin/../lib/gcc/i386-unknown-linux/4.7.x"
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     -ccc-host-triple i386-unknown-linux -m32 \
-// RUN:     -ccc-install-dir %S/Inputs/gcc_version_parsing3 \
+// RUN:     -ccc-install-dir %S/Inputs/gcc_version_parsing3/bin \
 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-GCC-VERSION3 %s
 // CHECK-GCC-VERSION3: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
-// CHECK-GCC-VERSION3: "{{.*}}/Inputs/gcc_version_parsing3/lib/gcc/i386-unknown-linux/4.7.99-rc5/crtbegin.o"
-// CHECK-GCC-VERSION3: "-L{{.*}}/Inputs/gcc_version_parsing3/lib/gcc/i386-unknown-linux/4.7.99-rc5"
+// CHECK-GCC-VERSION3: "{{.*}}/Inputs/gcc_version_parsing3/bin/../lib/gcc/i386-unknown-linux/4.7.99-rc5/crtbegin.o"
+// CHECK-GCC-VERSION3: "-L{{.*}}/Inputs/gcc_version_parsing3/bin/../lib/gcc/i386-unknown-linux/4.7.99-rc5"