[cfe-commits] r143900 - in /cfe/trunk/lib/Driver: ToolChains.cpp ToolChains.h

Chandler Carruth chandlerc at gmail.com
Sun Nov 6 15:39:37 PST 2011


Author: chandlerc
Date: Sun Nov  6 17:39:37 2011
New Revision: 143900

URL: http://llvm.org/viewvc/llvm-project?rev=143900&view=rev
Log:
Begin lifting some of the one-off checking logic into generic helper
routines on the base toolchain class.

Modified:
    cfe/trunk/lib/Driver/ToolChains.cpp
    cfe/trunk/lib/Driver/ToolChains.h

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=143900&r1=143899&r2=143900&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Sun Nov  6 17:39:37 2011
@@ -2011,9 +2011,6 @@
     return;
 
   const llvm::Triple &TargetTriple = getTriple();
-  const llvm::Triple::ArchType TargetArch = TargetTriple.getArch();
-  bool IsTarget64Bit = (TargetArch == llvm::Triple::x86_64 ||
-                        TargetArch == llvm::Triple::ppc64);
 
   StringRef CxxIncludeRoot(CXX_INCLUDE_ROOT);
   if (!CxxIncludeRoot.empty()) {
@@ -2023,8 +2020,8 @@
 
     addLibStdCXXIncludePaths(
       CxxIncludeRoot,
-      CxxIncludeArch + (IsTarget64Bit ? CXX_INCLUDE_64BIT_DIR
-                                      : CXX_INCLUDE_32BIT_DIR),
+      CxxIncludeArch + (isTarget64Bit() ? CXX_INCLUDE_64BIT_DIR
+                                        : CXX_INCLUDE_32BIT_DIR),
       DriverArgs, CC1Args);
     return;
   }
@@ -2034,6 +2031,7 @@
   // mismatches of just bit width.
   llvm::Triple::ArchType HostArch =
     llvm::Triple(getDriver().DefaultHostTriple).getArch();
+  llvm::Triple::ArchType TargetArch = TargetTriple.getArch();
   StringRef Suffix;
   if ((HostArch == llvm::Triple::x86 && TargetArch == llvm::Triple::x86_64) ||
       (HostArch == llvm::Triple::ppc && TargetArch == llvm::Triple::ppc64))

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=143900&r1=143899&r2=143900&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Sun Nov  6 17:39:37 2011
@@ -118,6 +118,21 @@
   virtual bool IsUnwindTablesDefault() const;
   virtual const char *GetDefaultRelocationModel() const;
   virtual const char *GetForcedPicModel() const;
+
+protected:
+  /// \name ToolChain Implementation Helper Functions
+  /// @{
+
+  /// \brief Check whether the target triple's architecture is 64-bits.
+  bool isTarget64Bit() const {
+    return (getTriple().getArch() == llvm::Triple::x86_64 ||
+            getTriple().getArch() == llvm::Triple::ppc64);
+  }
+  /// \brief Check whether the target triple's architecture is 32-bits.
+  /// FIXME: This should likely do more than just negate the 64-bit query.
+  bool isTarget32Bit() const { return !isTarget64Bit(); }
+
+  /// @}
 };
 
 /// Darwin - The base Darwin tool chain.





More information about the cfe-commits mailing list