[cfe-commits] r67754 - in /cfe/trunk: include/clang/Driver/Driver.h lib/Driver/Driver.cpp lib/Driver/HostInfo.cpp

Daniel Dunbar daniel at zuster.org
Thu Mar 26 08:58:36 PDT 2009


Author: ddunbar
Date: Thu Mar 26 10:58:36 2009
New Revision: 67754

URL: http://llvm.org/viewvc/llvm-project?rev=67754&view=rev
Log:
Driver: Move GetReleaseVersion to static Driver::GetReleaseVersion method.

Modified:
    cfe/trunk/include/clang/Driver/Driver.h
    cfe/trunk/lib/Driver/Driver.cpp
    cfe/trunk/lib/Driver/HostInfo.cpp

Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=67754&r1=67753&r2=67754&view=diff

==============================================================================
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Thu Mar 26 10:58:36 2009
@@ -235,6 +235,17 @@
                               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

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=67754&r1=67753&r2=67754&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Thu Mar 26 10:58:36 2009
@@ -1029,3 +1029,42 @@
 
   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;
+}

Modified: cfe/trunk/lib/Driver/HostInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/HostInfo.cpp?rev=67754&r1=67753&r2=67754&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/HostInfo.cpp (original)
+++ cfe/trunk/lib/Driver/HostInfo.cpp Thu Mar 26 10:58:36 2009
@@ -72,37 +72,6 @@
                                   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 @@
   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;
   }





More information about the cfe-commits mailing list