add a hack to allow parsing negative minint. rdar://7751341
authorChris Lattner <sabre@nondot.org>
Sat, 13 Mar 2010 19:25:13 +0000 (19:25 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 13 Mar 2010 19:25:13 +0000 (19:25 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98442 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MCParser/AsmLexer.cpp

index 482eefd93e04a8fb04d7e604659dbe05df6334ca..22c8d762df3a5c8b1182cd09c38d6dbc707d7993 100644 (file)
@@ -140,8 +140,14 @@ AsmToken AsmLexer::LexDigit() {
     StringRef Result(TokStart, CurPtr - TokStart);
     
     long long Value;
-    if (Result.getAsInteger(10, Value))
-      return ReturnError(TokStart, "Invalid decimal number");
+    if (Result.getAsInteger(10, Value)) {
+      // We have to handle minint_as_a_positive_value specially, because
+      // - minint_as_a_positive_value = minint and it is valid.
+      if (Result == "9223372036854775808")
+        Value = -9223372036854775808ULL;
+      else
+        return ReturnError(TokStart, "Invalid decimal number");
+    }
     return AsmToken(AsmToken::Integer, Result, Value);
   }