]> granicus.if.org Git - clang/commitdiff
Driver: Move GetReleaseVersion to static Driver::GetReleaseVersion method.
authorDaniel Dunbar <daniel@zuster.org>
Thu, 26 Mar 2009 15:58:36 +0000 (15:58 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 26 Mar 2009 15:58:36 +0000 (15:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67754 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/Driver.h
lib/Driver/Driver.cpp
lib/Driver/HostInfo.cpp

index 4935acc66da878699e4f74aece26efb14b4e8dfb..cdcb97691f1188cb2c69da55f95612e9204a0b50 100644 (file)
@@ -235,6 +235,17 @@ public:
                               const std::string &ArchName) const;
 
   /// @}
+
+  /// GetReleaseVersion - Parse (([0-9]+)(.([0-9]+)(.([0-9]+)?))?)? and
+  /// return the grouped values as integers. Numbers which are not
+  /// provided are set to 0.
+  ///
+  /// \return True if the entire string was parsed (9.2), or all
+  /// groups were parsed (10.3.5extrastuff). HadExtra is true if all
+  /// groups were parsed but extra characters remain at the end.
+  static bool GetReleaseVersion(const char *Str, unsigned &Major, 
+                                unsigned &Minor, unsigned &Micro,
+                                bool &HadExtra);
 };
 
 } // end namespace driver
index dc303ad0498cdb612b0dbd6e38bbf2412518e2f6..1562fde14cab14d8581e78af042e19c0ce99e0f3 100644 (file)
@@ -1029,3 +1029,42 @@ bool Driver::ShouldUseClangCompiler(const Compilation &C, const JobAction &JA,
 
   return true;
 }
+
+/// GetReleaseVersion - Parse (([0-9]+)(.([0-9]+)(.([0-9]+)?))?)? and
+/// return the grouped values as integers. Numbers which are not
+/// provided are set to 0.
+///
+/// \return True if the entire string was parsed (9.2), or all groups
+/// were parsed (10.3.5extrastuff).
+bool Driver::GetReleaseVersion(const char *Str, unsigned &Major, 
+                               unsigned &Minor, unsigned &Micro,
+                               bool &HadExtra) {
+  HadExtra = false;
+
+  Major = Minor = Micro = 0;
+  if (*Str == '\0') 
+    return true;
+
+  char *End;
+  Major = (unsigned) strtol(Str, &End, 10);
+  if (*Str != '\0' && *End == '\0')
+    return true;
+  if (*End != '.')
+    return false;
+  
+  Str = End+1;
+  Minor = (unsigned) strtol(Str, &End, 10);
+  if (*Str != '\0' && *End == '\0')
+    return true;
+  if (*End != '.')
+    return false;
+
+  Str = End+1;
+  Micro = (unsigned) strtol(Str, &End, 10);
+  if (*Str != '\0' && *End == '\0')
+    return true;
+  if (Str == End)
+    return false;
+  HadExtra = true;
+  return true;
+}
index 8f762095b614b2e897154d4e1b6f0565336252b9..c02267fbdc8c172acf53d4ceb64106f37c4db11b 100644 (file)
@@ -72,37 +72,6 @@ public:
                                   const char *ArchName) const;
 };
 
-/// GetReleaseVersion - Parse (([0-9]+)(.([0-9]+)(.([0-9]+)?))?)? and
-/// return the grouped values as integers. Numbers which are not
-/// provided are set to 0.
-///
-/// \return True if the entire string was parsed (9.2), or all groups
-/// were parsed (10.3.5extrastuff).
-static bool GetReleaseVersion(const char *Str, unsigned &Major, 
-                              unsigned &Minor, unsigned &Micro) {
-  Major = Minor = Micro = 0;
-  if (*Str == '\0') 
-    return true;
-
-  char *End;
-  Major = (unsigned) strtol(Str, &End, 10);
-  if (*Str != '\0' && *End == '\0')
-    return true;
-  if (*End != '.')
-    return false;
-  
-  Str = End+1;
-  Minor = (unsigned) strtol(Str, &End, 10);
-  if (*Str != '\0' && *End == '\0')
-    return true;
-  if (*End != '.')
-    return false;
-
-  Str = End+1;
-  Micro = (unsigned) strtol(Str, &End, 10);
-  return true;
-}
-
 DarwinHostInfo::DarwinHostInfo(const Driver &D, const char *_Arch, 
                                const char *_Platform, const char *_OS) 
   : HostInfo(D, _Arch, _Platform, _OS) {
@@ -114,8 +83,9 @@ DarwinHostInfo::DarwinHostInfo(const Driver &D, const char *_Arch,
   assert(memcmp(&getOSName()[0], "darwin", 6) == 0 &&
          "Unknown Darwin platform.");
   const char *Release = &getOSName()[6];
-  if (!GetReleaseVersion(Release, DarwinVersion[0], DarwinVersion[1], 
-                         DarwinVersion[2])) {
+  bool HadExtra;
+  if (!Driver::GetReleaseVersion(Release, DarwinVersion[0], DarwinVersion[1], 
+                                 DarwinVersion[2], HadExtra)) {
     D.Diag(clang::diag::err_drv_invalid_darwin_version)
       << Release;
   }