[cfe-commits] r56873 - in /cfe/trunk: Driver/clang.cpp lib/Basic/Targets.cpp
Chris Lattner
sabre at nondot.org
Tue Sep 30 13:30:12 PDT 2008
Author: lattner
Date: Tue Sep 30 15:30:12 2008
New Revision: 56873
URL: http://llvm.org/viewvc/llvm-project?rev=56873&view=rev
Log:
Handle minor version numbers in __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
like "10.3.9"
Modified:
cfe/trunk/Driver/clang.cpp
cfe/trunk/lib/Basic/Targets.cpp
Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=56873&r1=56872&r2=56873&view=diff
==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Tue Sep 30 15:30:12 2008
@@ -654,21 +654,16 @@
char *End = 0;
VersionNum = (int)strtol(Start, &End, 10);
+ // The version number must be in the range 0-9.
+ MacOSVersionMinIsInvalid = (unsigned)VersionNum > 9;
+
// Turn MacOSVersionMin into a darwin number: e.g. 10.3.9 is 3 -> 7.
Triple += llvm::itostr(VersionNum+4);
- if (End[0] == '.') { // 10.4.17 is ok.
- // Add the period piece (.17) to the end of the triple. This gives us
- // something like ...-darwin8.17
+ if (End[0] == '.' && isdigit(End[1]) && End[2] == '\0') { // 10.4.7 is ok.
+ // Add the period piece (.7) to the end of the triple. This gives us
+ // something like ...-darwin8.7
Triple += End;
-
- // Verify that the rest after the number are all digits.
- for (++End; isdigit(*End); ++End)
- /*skip digits*/;
-
- // If there were any non-digits after the number, reject it.
- MacOSVersionMinIsInvalid = *End != '\0';
-
} else if (End[0] != '\0') { // "10.4" is ok. 10.4x is not.
MacOSVersionMinIsInvalid = true;
}
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=56873&r1=56872&r2=56873&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Sep 30 15:30:12 2008
@@ -17,8 +17,6 @@
#include "clang/Basic/TargetInfo.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/APFloat.h"
-#include <cstdlib>
-
using namespace clang;
//===----------------------------------------------------------------------===//
@@ -47,16 +45,30 @@
// Figure out which "darwin number" the target triple is. "darwin9" -> 10.5.
const char *Darwin = strstr(Triple, "-darwin");
if (Darwin) {
+ char DarwinStr[] = "1000";
Darwin += strlen("-darwin");
- if (Darwin[0] >= '1' && Darwin[0] <= '9') {
- unsigned DarwinNo = atoi(Darwin);
- if (DarwinNo > 4) {
- char DarwinStr[] = "10x0";
+ if (Darwin[0] >= '0' && Darwin[0] <= '9') {
+ unsigned DarwinNo = Darwin[0]-'0';
+ ++Darwin;
+
+ // Handle "darwin11".
+ if (DarwinNo == 1 && Darwin[0] >= '0' && Darwin[0] <= '9') {
+ DarwinNo = 10+Darwin[0]-'0';
+ ++Darwin;
+ }
+
+ if (DarwinNo >= 4 && DarwinNo <= 13) { // 10.0-10.9
// darwin7 -> 1030, darwin8 -> 1040, darwin9 -> 1050, etc.
DarwinStr[2] = '0' + DarwinNo-4;
- Define(Defs, "__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__",DarwinStr);
}
+
+ // Handle minor version: 10.4.9 -> darwin8.9 -> "1049"
+ if (Darwin[0] == '.' && Darwin[1] >= '0' && Darwin[1] <= '9' &&
+ Darwin[2] == '\0')
+ DarwinStr[3] = Darwin[1];
+
}
+ Define(Defs, "__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__", DarwinStr);
}
}
More information about the cfe-commits
mailing list