Add support for having different c++ search dirs with -m32 and -m64. So far
this is only used in darwin10, 64 bit ubuntu 9.10 and 64 bit openSUSE 11.1.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84115 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Frontend/InitHeaderSearch.cpp b/lib/Frontend/InitHeaderSearch.cpp
index eb5b433..822a5ba 100644
--- a/lib/Frontend/InitHeaderSearch.cpp
+++ b/lib/Frontend/InitHeaderSearch.cpp
@@ -103,10 +103,18 @@
 }
 
 void InitHeaderSearch::AddGnuCPlusPlusIncludePaths(const std::string &Base,
-                                                  const char *Arch) {
-    AddPath(Base, System, true, false, false);
-    AddPath(Base + "/" + Arch, System, true, false, false);
-    AddPath(Base + "/backward", System, true, false, false);
+                                                   const char *Dir32,
+                                                   const char *Dir64,
+                                                   const llvm::Triple &triple) {
+  llvm::Triple::ArchType arch = triple.getArch();
+  bool is64bit = arch == llvm::Triple::ppc64 || arch == llvm::Triple::x86_64;
+
+  AddPath(Base, System, true, false, false);
+  if (is64bit)
+    AddPath(Base + "/" + Dir64, System, true, false, false);
+  else
+    AddPath(Base + "/" + Dir32, System, true, false, false);
+  AddPath(Base + "/backward", System, true, false, false);
 }
 
 void InitHeaderSearch::AddMinGWCPlusPlusIncludePaths(const std::string &Base,
@@ -234,7 +242,7 @@
 }
 
 void InitHeaderSearch::AddDefaultSystemIncludePaths(const LangOptions &Lang,
-                                                   const llvm::Triple &triple) {
+                                                    const llvm::Triple &triple) {
   // FIXME: temporary hack: hard-coded paths.
   llvm::Triple::OSType os = triple.getOS();
 
@@ -299,56 +307,91 @@
       switch (os) {
         case llvm::Triple::Darwin:
           AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
-                                      "i686-apple-darwin10");
+                                      "i686-apple-darwin10",
+                                      "i686-apple-darwin10/x86_64",
+                                      triple);
           AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.0.0",
-                                      "i686-apple-darwin8");
+                                      "i686-apple-darwin8",
+                                      "i686-apple-darwin8",
+                                      triple);
           break;
         case llvm::Triple::Linux:
           // Ubuntu 7.10 - Gutsy Gibbon
           AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1.3",
-                                      "i486-linux-gnu");
+                                      "i486-linux-gnu",
+                                      "i486-linux-gnu",
+                                      triple);
           // Ubuntu 9.04
           AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.3",
-                                      "x86_64-linux-gnu");
+                                      "x86_64-linux-gnu/32",
+                                      "x86_64-linux-gnu",
+                                      triple);
           // Fedora 8
           AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1.2",
-                                      "i386-redhat-linux");
+                                      "i386-redhat-linux",
+                                      "i386-redhat-linux",
+                                      triple);
           // Fedora 9
           AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.0",
-                                      "i386-redhat-linux");
+                                      "i386-redhat-linux",
+                                      "i386-redhat-linux",
+                                      triple);
           // Fedora 10
           AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.2",
-                                      "i386-redhat-linux");
-          // openSUSE 11.1
+                                      "i386-redhat-linux",
+                                      "i386-redhat-linux",
+                                      triple);
+          // openSUSE 11.1 32 bit
           AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3",
-                                      "i586-suse-linux");
+                                      "i586-suse-linux",
+                                      "i586-suse-linux",
+                                      triple);
+          // openSUSE 11.1 64 bit
           AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3",
-                                      "x86_64-suse-linux");
+                                      "x86_64-suse-linux/32",
+                                      "x86_64-suse-linux",
+                                      triple);
           // openSUSE 11.2
           AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4",
-                                      "i586-suse-linux");
+                                      "i586-suse-linux",
+                                      "i586-suse-linux",
+                                      triple);
           AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4",
-                                      "x86_64-suse-linux");
+                                      "x86_64-suse-linux",
+                                      "x86_64-suse-linux",
+                                      triple);
           // Arch Linux 2008-06-24
           AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.1",
-                                      "i686-pc-linux-gnu");
+                                      "i686-pc-linux-gnu",
+                                      "i686-pc-linux-gnu",
+                                      triple);
           AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.1",
-                                      "x86_64-unknown-linux-gnu");
+                                      "x86_64-unknown-linux-gnu",
+                                      "x86_64-unknown-linux-gnu",
+                                      triple);
           // Gentoo x86 2009.0 stable
           AddGnuCPlusPlusIncludePaths(
              "/usr/lib/gcc/i686-pc-linux-gnu/4.3.2/include/g++-v4",
-             "i686-pc-linux-gnu");
+             "i686-pc-linux-gnu",
+             "i686-pc-linux-gnu",
+             triple);
           // Gentoo x86 2008.0 stable
           AddGnuCPlusPlusIncludePaths(
              "/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4",
-             "i686-pc-linux-gnu");
+             "i686-pc-linux-gnu",
+             "i686-pc-linux-gnu",
+             triple);
           // Ubuntu 8.10
           AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3",
-                                      "i486-pc-linux-gnu");
+                                      "i486-pc-linux-gnu",
+                                      "i486-pc-linux-gnu",
+                                      triple);
           // Gentoo amd64 stable
           AddGnuCPlusPlusIncludePaths(
              "/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/include/g++-v4",
-             "i686-pc-linux-gnu");
+             "i686-pc-linux-gnu",
+             "i686-pc-linux-gnu",
+             triple);
           break;
         case llvm::Triple::FreeBSD:
           // DragonFly
@@ -359,7 +402,9 @@
         case llvm::Triple::Solaris:
           // AuroraUX
           AddGnuCPlusPlusIncludePaths("/opt/gcc4/include/c++/4.2.4",
-                                      "i386-pc-solaris2.11");
+                                      "i386-pc-solaris2.11",
+                                      "i386-pc-solaris2.11",
+                                      triple);
           break;
         default:
           break;