Fix MSVC incompatibilities.

llvm-svn: 152389
diff --git a/lld/lib/Core/YamlReader.cpp b/lld/lib/Core/YamlReader.cpp
index 31f999e..98201f8 100644
--- a/lld/lib/Core/YamlReader.cpp
+++ b/lld/lib/Core/YamlReader.cpp
@@ -22,6 +22,7 @@
 
 #include "lld/Platform/Platform.h"
 
+#include "llvm/ADT/APInt.h"
 #include "llvm/ADT/OwningPtr.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -934,7 +935,9 @@
           haveAtom = true;
         }
         else if (strcmp(entry->key, KeyValues::valueKeyword) == 0) {
-          llvm::StringRef(entry->value).getAsInteger(0, atomState._value);
+          llvm::APInt Val;
+          llvm::StringRef(entry->value).getAsInteger(0, Val);
+          atomState._value = Val.getZExtValue();
           haveAtom = true;
         }
         else {
@@ -953,8 +956,9 @@
           haveFixup = true;
         } 
         else if (strcmp(entry->key, KeyValues::fixupsOffsetKeyword) == 0) {
-          llvm::StringRef(entry->value).getAsInteger(0, 
-                                              atomState._ref._offsetInAtom);
+          llvm::APInt Val;
+          llvm::StringRef(entry->value).getAsInteger(0, Val);
+          atomState._ref._offsetInAtom = Val.getZExtValue();
           haveFixup = true;
         } 
         else if (strcmp(entry->key, KeyValues::fixupsTargetKeyword) == 0) {
@@ -962,8 +966,19 @@
           haveFixup = true;
         }
         else if (strcmp(entry->key, KeyValues::fixupsAddendKeyword) == 0) {
-          llvm::StringRef(entry->value).getAsInteger(0, 
-                                              atomState._ref._addend);
+          llvm::APInt Val;
+          // HACK: getAsInteger for APInt doesn't handle negative values
+          //       the same as other getAsInteger functions. And getAsInteger
+          //       doesn't work on all platforms for {,u}int64_t. So manually
+          //       handle this until getAsInteger is fixed.
+          bool IsNeg = false;
+          llvm::StringRef Addend(entry->value);
+          if (Addend.find('-') == 0) {
+            IsNeg = true;
+            Addend = Addend.substr(1);
+          }
+          Addend.getAsInteger(0, Val);
+          atomState._ref._addend = Val.getSExtValue() * (IsNeg ? -1 : 1);
           haveFixup = true;
         }
       }