[cfe-commits] r67388 - in /cfe/trunk: include/clang/Basic/DiagnosticDriverKinds.def include/clang/Basic/DiagnosticDriverKinds.td lib/Driver/HostInfo.cpp
Daniel Dunbar
daniel at zuster.org
Fri Mar 20 11:21:51 PDT 2009
Author: ddunbar
Date: Fri Mar 20 13:21:51 2009
New Revision: 67388
URL: http://llvm.org/viewvc/llvm-project?rev=67388&view=rev
Log:
Driver: Parse Darwin version out of target triple.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.def
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Driver/HostInfo.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.def?rev=67388&r1=67387&r2=67388&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.def Fri Mar 20 13:21:51 2009
@@ -36,6 +36,8 @@
"unable to remove file: %0")
DIAG(err_drv_command_failure, ERROR,
"unable to execute command: %0")
+DIAG(err_drv_invalid_darwin_version, ERROR,
+ "invalid Darwin version number: %0")
DIAG(warn_drv_input_file_unused, WARNING,
"%0: '%1' input file unused when '%2' is present")
Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=67388&r1=67387&r2=67388&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri Mar 20 13:21:51 2009
@@ -29,6 +29,8 @@
"unable to remove file: %0">;
def err_drv_command_failure : Error<
"unable to execute command: %0">;
+def err_drv_invalid_darwin_version : Error<
+ "invalid Darwin version number: %0">;
def warn_drv_input_file_unused : Warning<
"%0: '%1' input file unused when '%2' is present">;
Modified: cfe/trunk/lib/Driver/HostInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/HostInfo.cpp?rev=67388&r1=67387&r2=67388&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/HostInfo.cpp (original)
+++ cfe/trunk/lib/Driver/HostInfo.cpp Fri Mar 20 13:21:51 2009
@@ -11,6 +11,8 @@
#include "clang/Driver/Arg.h"
#include "clang/Driver/ArgList.h"
+#include "clang/Driver/Driver.h"
+#include "clang/Driver/DriverDiagnostic.h"
#include "clang/Driver/Option.h"
#include "clang/Driver/Options.h"
@@ -59,6 +61,37 @@
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) {
@@ -67,7 +100,14 @@
getArchName() == "ppc" || getArchName() == "ppc64") &&
"Unknown Darwin arch.");
- // FIXME: How to deal with errors?
+ assert(memcmp(&getOSName()[0], "darwin", 6) == 0 &&
+ "Unknown Darwin platform.");
+ const char *Release = &getOSName()[6];
+ if (!GetReleaseVersion(Release, DarwinVersion[0], DarwinVersion[1],
+ DarwinVersion[2])) {
+ D.Diag(clang::diag::err_drv_invalid_darwin_version)
+ << Release;
+ }
// We can only call 4.2.1 for now.
GCCVersion[0] = 4;
More information about the cfe-commits
mailing list