Handle lshr for i128 correctly on SPU also when
[oota-llvm.git] / lib / System / Path.cpp
index 4445c667d86e92f7784ef5d95536a9e3df9664af..ba47b51ff0980acf82b5eaed844e74240c03b62c 100644 (file)
@@ -104,7 +104,7 @@ sys::IdentifyFileType(const char *magic, unsigned length) {
         case 2: return Mach_O_Executable_FileType;
         case 3: return Mach_O_FixedVirtualMemorySharedLib_FileType;
         case 4: return Mach_O_Core_FileType;
-        case 5: return Mach_O_PreloadExectuable_FileType;
+        case 5: return Mach_O_PreloadExecutable_FileType;
         case 6: return Mach_O_DynamicallyLinkedSharedLib_FileType;
         case 7: return Mach_O_DynamicLinker_FileType;
         case 8: return Mach_O_Bundle_FileType;
@@ -127,6 +127,10 @@ sys::IdentifyFileType(const char *magic, unsigned length) {
       if (magic[1] == 0x02)
         return COFF_FileType;
       break;
+    case 0x64: // x86-64 Windows.
+      if (magic[1] == char(0x86))
+        return COFF_FileType;
+      break;
 
     default:
       break;
@@ -156,6 +160,20 @@ Path::isDynamicLibrary() const {
   return false;
 }
 
+bool
+Path::isObjectFile() const {
+  std::string Magic;
+  if (getMagicNumber(Magic, 64))
+    if (IdentifyFileType(Magic.c_str(),
+                         static_cast<unsigned>(Magic.length()))
+        != Unknown_FileType) {
+      // Everything in LLVMFileType is currently an object file.
+      return true;
+    }
+
+  return false;
+}
+
 Path
 Path::FindLibrary(std::string& name) {
   std::vector<sys::Path> LibPaths;
@@ -174,7 +192,22 @@ Path::FindLibrary(std::string& name) {
 }
 
 StringRef Path::GetDLLSuffix() {
-  return LTDL_SHLIB_EXT;
+  return &(LTDL_SHLIB_EXT[1]);
+}
+
+bool
+Path::appendSuffix(StringRef suffix) {
+  if (!suffix.empty()) {
+    std::string save(path);
+    path.append(".");
+    path.append(suffix);
+    if (!isValid()) {
+      path = save;
+      return false;
+    }
+  }
+
+  return true;
 }
 
 bool