For PR797:
Rid the Assembly Parser of exceptions. This is a really gross hack but it
will do until the Assembly Parser is re-written as a recursive descent.
The basic premise is that wherever the old "ThrowException" function was
called (new name: GenerateError) we set a flag (TriggerError). Every
production checks that flag and calls YYERROR if it is set. Additionally,
each call to ThrowException in the grammar is replaced with GEN_ERROR
which calls GenerateError and then YYERROR immediately. This prevents
the remaining production from continuing after an error condition.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29763 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AsmParser/Lexer.l b/lib/AsmParser/Lexer.l
index dc94cca..fd75245 100644
--- a/lib/AsmParser/Lexer.l
+++ b/lib/AsmParser/Lexer.l
@@ -59,7 +59,7 @@
Result *= 10;
Result += *Buffer-'0';
if (Result < OldRes) // Uh, oh, overflow detected!!!
- ThrowException("constant bigger than 64 bits detected!");
+ GenerateError("constant bigger than 64 bits detected!");
}
return Result;
}
@@ -78,7 +78,7 @@
Result += C-'a'+10;
if (Result < OldRes) // Uh, oh, overflow detected!!!
- ThrowException("constant bigger than 64 bits detected!");
+ GenerateError("constant bigger than 64 bits detected!");
}
return Result;
}
@@ -116,7 +116,7 @@
char Tmp = BIn[3]; BIn[3] = 0; // Terminate string
*BOut = (char)strtol(BIn+1, 0, 16); // Convert to number
if (!AllowNull && !*BOut)
- ThrowException("String literal cannot accept \\00 escape!");
+ GenerateError("String literal cannot accept \\00 escape!");
BIn[3] = Tmp; // Restore character
BIn += 3; // Skip over handled chars
@@ -315,7 +315,7 @@
uint64_t Val = atoull(yytext+1);
// +1: we have bigger negative range
if (Val > (uint64_t)INT64_MAX+1)
- ThrowException("Constant too large for signed 64 bits!");
+ GenerateError("Constant too large for signed 64 bits!");
llvmAsmlval.SInt64Val = -Val;
return ESINT64VAL;
}
@@ -327,7 +327,7 @@
{EPInteger} {
uint64_t Val = atoull(yytext+1);
if ((unsigned)Val != Val)
- ThrowException("Invalid value number (too large)!");
+ GenerateError("Invalid value number (too large)!");
llvmAsmlval.UIntVal = unsigned(Val);
return UINTVAL;
}
@@ -335,7 +335,7 @@
uint64_t Val = atoull(yytext+2);
// +1: we have bigger negative range
if (Val > (uint64_t)INT32_MAX+1)
- ThrowException("Constant too large for signed 32 bits!");
+ GenerateError("Constant too large for signed 32 bits!");
llvmAsmlval.SIntVal = (int)-Val;
return SINTVAL;
}
@@ -355,4 +355,3 @@
. { return yytext[0]; }
%%
-