[Lldb-commits] [lldb] r235892 - Make sure versions are valid before we try to use them. Also check for invalid versions[0] by comparing it to UINT32_MAX instead of 0.

Greg Clayton gclayton at apple.com
Mon Apr 27 09:49:57 PDT 2015


Author: gclayton
Date: Mon Apr 27 11:49:57 2015
New Revision: 235892

URL: http://llvm.org/viewvc/llvm-project?rev=235892&view=rev
Log:
Make sure versions are valid before we try to use them. Also check for invalid versions[0] by comparing it to UINT32_MAX instead of 0.


Modified:
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=235892&r1=235891&r2=235892&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Mon Apr 27 11:49:57 2015
@@ -1479,8 +1479,9 @@ PlatformDarwin::AddClangModuleCompilatio
             break;
     }
 
+    bool versions_valid = false;
     if (use_current_os_version)
-        GetOSVersion(versions[0], versions[1], versions[2]);
+        versions_valid = GetOSVersion(versions[0], versions[1], versions[2]);
     else if (target)
     {
         // Our OS doesn't match our executable so we need to get the min OS version from the object file
@@ -1489,14 +1490,17 @@ PlatformDarwin::AddClangModuleCompilatio
         {
             ObjectFile *object_file = exe_module_sp->GetObjectFile();
             if (object_file)
-                object_file->GetMinimumOSVersion(versions, 3);
+                versions_valid = object_file->GetMinimumOSVersion(versions, 3) > 0;
         }
     }
     // Only add the version-min options if we got a version from somewhere
-    if (versions[0])
+    if (versions_valid && versions[0] != UINT32_MAX)
     {
+        // Make any invalid versions be zero if needed
+        if (versions[1] == UINT32_MAX)
+            versions[1] = 0;
         if (versions[2] == UINT32_MAX)
-            versions[2] = 0; // FIXME who actually likes this behavior?
+            versions[2] = 0;
         
         switch (sdk_type)
         {





More information about the lldb-commits mailing list