for (char *BIn = Buffer; *BIn; ) {
if (BIn[0] == '\\' && isxdigit(BIn[1]) && isxdigit(BIn[2])) {
char Tmp = BIn[3]; BIn[3] = 0; // Terminate string
- *BOut = strtol(BIn+1, 0, 16); // Convert to number
+ *BOut = (char)strtol(BIn+1, 0, 16); // Convert to number
if (!AllowNull && !*BOut)
ThrowException("String literal cannot accept \\00 escape!");
/* Label identifiers end with a colon */
Label [-a-zA-Z$._0-9]+:
+QuoteLabel \"[^\"]+\":
/* Quoted names can contain any character except " and \ */
StringConstant \"[^\"]*\"
implementation { return IMPLEMENTATION; }
zeroinitializer { return ZEROINITIALIZER; }
\.\.\. { return DOTDOTDOT; }
+undef { return UNDEF; }
null { return NULL_TOK; }
to { return TO; }
except { RET_TOK(TermOpVal, Unwind, UNWIND); }
switch { RET_TOK(TermOpVal, Switch, SWITCH); }
invoke { RET_TOK(TermOpVal, Invoke, INVOKE); }
unwind { RET_TOK(TermOpVal, Unwind, UNWIND); }
-
+unreachable { RET_TOK(TermOpVal, Unreachable, UNREACHABLE); }
malloc { RET_TOK(MemOpVal, Malloc, MALLOC); }
alloca { RET_TOK(MemOpVal, Alloca, ALLOCA); }
llvmAsmlval.StrVal = strdup(yytext);
return LABELSTR;
}
+{QuoteLabel} {
+ yytext[strlen(yytext)-2] = 0; // nuke colon, end quote
+ UnEscapeLexed(yytext+1);
+ llvmAsmlval.StrVal = strdup(yytext+1);
+ return LABELSTR;
+ }
{StringConstant} { // Note that we cannot unescape a string constant here! The
// string constant might contain a \00 which would not be
return yytext[0] == 's' ? ESINT64VAL : EUINT64VAL;
}
-{EPInteger} { llvmAsmlval.UIntVal = atoull(yytext+1); return UINTVAL; }
+{EPInteger} {
+ uint64_t Val = atoull(yytext+1);
+ if ((unsigned)Val != Val)
+ ThrowException("Invalid value number (too large)!");
+ llvmAsmlval.UIntVal = unsigned(Val);
+ return UINTVAL;
+ }
{ENInteger} {
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!");
- llvmAsmlval.SIntVal = -Val;
+ llvmAsmlval.SIntVal = (int)-Val;
return SINTVAL;
}