mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-21 03:28:31 +00:00
Remove spurious warnings from GCC:
warning: suggest a space before ';' or explicit braces around empty body in 'for' statement Patch by Mike Stump (modified slightly by yours truly). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45071 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
87a702be1a
commit
2c6fd8c7ce
@ -54,7 +54,7 @@ static uint64_t HexIntToVal(const char *Buffer, const char *End) {
|
|||||||
Result += C-'A'+10;
|
Result += C-'A'+10;
|
||||||
else if (C >= 'a' && C <= 'f')
|
else if (C >= 'a' && C <= 'f')
|
||||||
Result += C-'a'+10;
|
Result += C-'a'+10;
|
||||||
|
|
||||||
if (Result < OldRes) { // Uh, oh, overflow detected!!!
|
if (Result < OldRes) { // Uh, oh, overflow detected!!!
|
||||||
GenerateError("constant bigger than 64 bits detected!");
|
GenerateError("constant bigger than 64 bits detected!");
|
||||||
return 0;
|
return 0;
|
||||||
@ -102,7 +102,7 @@ static void HexToIntPair(const char *Buffer, const char *End, uint64_t Pair[2]){
|
|||||||
// appropriate character.
|
// appropriate character.
|
||||||
static void UnEscapeLexed(std::string &Str) {
|
static void UnEscapeLexed(std::string &Str) {
|
||||||
if (Str.empty()) return;
|
if (Str.empty()) return;
|
||||||
|
|
||||||
char *Buffer = &Str[0], *EndBuffer = Buffer+Str.size();
|
char *Buffer = &Str[0], *EndBuffer = Buffer+Str.size();
|
||||||
char *BOut = Buffer;
|
char *BOut = Buffer;
|
||||||
for (char *BIn = Buffer; BIn != EndBuffer; ) {
|
for (char *BIn = Buffer; BIn != EndBuffer; ) {
|
||||||
@ -168,9 +168,9 @@ int LLLexer::getNextChar() {
|
|||||||
// a random nul in the file. Disambiguate that here.
|
// a random nul in the file. Disambiguate that here.
|
||||||
if (CurPtr-1 != CurBuf->getBufferEnd())
|
if (CurPtr-1 != CurBuf->getBufferEnd())
|
||||||
return 0; // Just whitespace.
|
return 0; // Just whitespace.
|
||||||
|
|
||||||
// Otherwise, return end of file.
|
// Otherwise, return end of file.
|
||||||
--CurPtr; // Another call to lex will return EOF again.
|
--CurPtr; // Another call to lex will return EOF again.
|
||||||
return EOF;
|
return EOF;
|
||||||
case '\n':
|
case '\n':
|
||||||
case '\r':
|
case '\r':
|
||||||
@ -180,24 +180,24 @@ int LLLexer::getNextChar() {
|
|||||||
if ((*CurPtr == '\n' || (*CurPtr == '\r')) &&
|
if ((*CurPtr == '\n' || (*CurPtr == '\r')) &&
|
||||||
*CurPtr != CurChar)
|
*CurPtr != CurChar)
|
||||||
++CurPtr; // Eat the two char newline sequence.
|
++CurPtr; // Eat the two char newline sequence.
|
||||||
|
|
||||||
++CurLineNo;
|
++CurLineNo;
|
||||||
return '\n';
|
return '\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int LLLexer::LexToken() {
|
int LLLexer::LexToken() {
|
||||||
TokStart = CurPtr;
|
TokStart = CurPtr;
|
||||||
|
|
||||||
int CurChar = getNextChar();
|
int CurChar = getNextChar();
|
||||||
|
|
||||||
switch (CurChar) {
|
switch (CurChar) {
|
||||||
default:
|
default:
|
||||||
// Handle letters: [a-zA-Z_]
|
// Handle letters: [a-zA-Z_]
|
||||||
if (isalpha(CurChar) || CurChar == '_')
|
if (isalpha(CurChar) || CurChar == '_')
|
||||||
return LexIdentifier();
|
return LexIdentifier();
|
||||||
|
|
||||||
return CurChar;
|
return CurChar;
|
||||||
case EOF: return YYEOF;
|
case EOF: return YYEOF;
|
||||||
case 0:
|
case 0:
|
||||||
@ -234,7 +234,7 @@ int LLLexer::LexToken() {
|
|||||||
return LexToken();
|
return LexToken();
|
||||||
case '0': case '1': case '2': case '3': case '4':
|
case '0': case '1': case '2': case '3': case '4':
|
||||||
case '5': case '6': case '7': case '8': case '9':
|
case '5': case '6': case '7': case '8': case '9':
|
||||||
case '-':
|
case '-':
|
||||||
return LexDigitOrNegative();
|
return LexDigitOrNegative();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -254,11 +254,11 @@ int LLLexer::LexAt() {
|
|||||||
// Handle AtStringConstant: @\"[^\"]*\"
|
// Handle AtStringConstant: @\"[^\"]*\"
|
||||||
if (CurPtr[0] == '"') {
|
if (CurPtr[0] == '"') {
|
||||||
++CurPtr;
|
++CurPtr;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int CurChar = getNextChar();
|
int CurChar = getNextChar();
|
||||||
|
|
||||||
if (CurChar == EOF) {
|
if (CurChar == EOF) {
|
||||||
GenerateError("End of file in global variable name");
|
GenerateError("End of file in global variable name");
|
||||||
return YYERROR;
|
return YYERROR;
|
||||||
}
|
}
|
||||||
@ -269,30 +269,31 @@ int LLLexer::LexAt() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle GlobalVarName: @[-a-zA-Z$._][-a-zA-Z$._0-9]*
|
// Handle GlobalVarName: @[-a-zA-Z$._][-a-zA-Z$._0-9]*
|
||||||
if (isalpha(CurPtr[0]) || CurPtr[0] == '-' || CurPtr[0] == '$' ||
|
if (isalpha(CurPtr[0]) || CurPtr[0] == '-' || CurPtr[0] == '$' ||
|
||||||
CurPtr[0] == '.' || CurPtr[0] == '_') {
|
CurPtr[0] == '.' || CurPtr[0] == '_') {
|
||||||
++CurPtr;
|
++CurPtr;
|
||||||
while (isalnum(CurPtr[0]) || CurPtr[0] == '-' || CurPtr[0] == '$' ||
|
while (isalnum(CurPtr[0]) || CurPtr[0] == '-' || CurPtr[0] == '$' ||
|
||||||
CurPtr[0] == '.' || CurPtr[0] == '_')
|
CurPtr[0] == '.' || CurPtr[0] == '_')
|
||||||
++CurPtr;
|
++CurPtr;
|
||||||
|
|
||||||
llvmAsmlval.StrVal = new std::string(TokStart+1, CurPtr); // Skip @
|
llvmAsmlval.StrVal = new std::string(TokStart+1, CurPtr); // Skip @
|
||||||
return GLOBALVAR;
|
return GLOBALVAR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle GlobalVarID: @[0-9]+
|
// Handle GlobalVarID: @[0-9]+
|
||||||
if (isdigit(CurPtr[0])) {
|
if (isdigit(CurPtr[0])) {
|
||||||
for (++CurPtr; isdigit(CurPtr[0]); ++CurPtr);
|
for (++CurPtr; isdigit(CurPtr[0]); ++CurPtr)
|
||||||
|
/*empty*/;
|
||||||
|
|
||||||
uint64_t Val = atoull(TokStart+1, CurPtr);
|
uint64_t Val = atoull(TokStart+1, CurPtr);
|
||||||
if ((unsigned)Val != Val)
|
if ((unsigned)Val != Val)
|
||||||
GenerateError("Invalid value number (too large)!");
|
GenerateError("Invalid value number (too large)!");
|
||||||
llvmAsmlval.UIntVal = unsigned(Val);
|
llvmAsmlval.UIntVal = unsigned(Val);
|
||||||
return GLOBALVAL_ID;
|
return GLOBALVAL_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
return '@';
|
return '@';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,11 +306,11 @@ int LLLexer::LexPercent() {
|
|||||||
// Handle PctStringConstant: %\"[^\"]*\"
|
// Handle PctStringConstant: %\"[^\"]*\"
|
||||||
if (CurPtr[0] == '"') {
|
if (CurPtr[0] == '"') {
|
||||||
++CurPtr;
|
++CurPtr;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int CurChar = getNextChar();
|
int CurChar = getNextChar();
|
||||||
|
|
||||||
if (CurChar == EOF) {
|
if (CurChar == EOF) {
|
||||||
GenerateError("End of file in local variable name");
|
GenerateError("End of file in local variable name");
|
||||||
return YYERROR;
|
return YYERROR;
|
||||||
}
|
}
|
||||||
@ -320,30 +321,31 @@ int LLLexer::LexPercent() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle LocalVarName: %[-a-zA-Z$._][-a-zA-Z$._0-9]*
|
// Handle LocalVarName: %[-a-zA-Z$._][-a-zA-Z$._0-9]*
|
||||||
if (isalpha(CurPtr[0]) || CurPtr[0] == '-' || CurPtr[0] == '$' ||
|
if (isalpha(CurPtr[0]) || CurPtr[0] == '-' || CurPtr[0] == '$' ||
|
||||||
CurPtr[0] == '.' || CurPtr[0] == '_') {
|
CurPtr[0] == '.' || CurPtr[0] == '_') {
|
||||||
++CurPtr;
|
++CurPtr;
|
||||||
while (isalnum(CurPtr[0]) || CurPtr[0] == '-' || CurPtr[0] == '$' ||
|
while (isalnum(CurPtr[0]) || CurPtr[0] == '-' || CurPtr[0] == '$' ||
|
||||||
CurPtr[0] == '.' || CurPtr[0] == '_')
|
CurPtr[0] == '.' || CurPtr[0] == '_')
|
||||||
++CurPtr;
|
++CurPtr;
|
||||||
|
|
||||||
llvmAsmlval.StrVal = new std::string(TokStart+1, CurPtr); // Skip %
|
llvmAsmlval.StrVal = new std::string(TokStart+1, CurPtr); // Skip %
|
||||||
return LOCALVAR;
|
return LOCALVAR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle LocalVarID: %[0-9]+
|
// Handle LocalVarID: %[0-9]+
|
||||||
if (isdigit(CurPtr[0])) {
|
if (isdigit(CurPtr[0])) {
|
||||||
for (++CurPtr; isdigit(CurPtr[0]); ++CurPtr);
|
for (++CurPtr; isdigit(CurPtr[0]); ++CurPtr)
|
||||||
|
/*empty*/;
|
||||||
|
|
||||||
uint64_t Val = atoull(TokStart+1, CurPtr);
|
uint64_t Val = atoull(TokStart+1, CurPtr);
|
||||||
if ((unsigned)Val != Val)
|
if ((unsigned)Val != Val)
|
||||||
GenerateError("Invalid value number (too large)!");
|
GenerateError("Invalid value number (too large)!");
|
||||||
llvmAsmlval.UIntVal = unsigned(Val);
|
llvmAsmlval.UIntVal = unsigned(Val);
|
||||||
return LOCALVAL_ID;
|
return LOCALVAL_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
return '%';
|
return '%';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,12 +355,12 @@ int LLLexer::LexPercent() {
|
|||||||
int LLLexer::LexQuote() {
|
int LLLexer::LexQuote() {
|
||||||
while (1) {
|
while (1) {
|
||||||
int CurChar = getNextChar();
|
int CurChar = getNextChar();
|
||||||
|
|
||||||
if (CurChar == EOF) {
|
if (CurChar == EOF) {
|
||||||
GenerateError("End of file in quoted string");
|
GenerateError("End of file in quoted string");
|
||||||
return YYERROR;
|
return YYERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CurChar != '"') continue;
|
if (CurChar != '"') continue;
|
||||||
|
|
||||||
if (CurPtr[0] != ':') {
|
if (CurPtr[0] != ':') {
|
||||||
@ -366,7 +368,7 @@ int LLLexer::LexQuote() {
|
|||||||
UnEscapeLexed(*llvmAsmlval.StrVal);
|
UnEscapeLexed(*llvmAsmlval.StrVal);
|
||||||
return STRINGCONSTANT;
|
return STRINGCONSTANT;
|
||||||
}
|
}
|
||||||
|
|
||||||
++CurPtr;
|
++CurPtr;
|
||||||
llvmAsmlval.StrVal = new std::string(TokStart+1, CurPtr-2);
|
llvmAsmlval.StrVal = new std::string(TokStart+1, CurPtr-2);
|
||||||
UnEscapeLexed(*llvmAsmlval.StrVal);
|
UnEscapeLexed(*llvmAsmlval.StrVal);
|
||||||
@ -395,26 +397,26 @@ int LLLexer::LexIdentifier() {
|
|||||||
const char *StartChar = CurPtr;
|
const char *StartChar = CurPtr;
|
||||||
const char *IntEnd = CurPtr[-1] == 'i' ? 0 : StartChar;
|
const char *IntEnd = CurPtr[-1] == 'i' ? 0 : StartChar;
|
||||||
const char *KeywordEnd = 0;
|
const char *KeywordEnd = 0;
|
||||||
|
|
||||||
for (; isLabelChar(*CurPtr); ++CurPtr) {
|
for (; isLabelChar(*CurPtr); ++CurPtr) {
|
||||||
// If we decide this is an integer, remember the end of the sequence.
|
// If we decide this is an integer, remember the end of the sequence.
|
||||||
if (!IntEnd && !isdigit(*CurPtr)) IntEnd = CurPtr;
|
if (!IntEnd && !isdigit(*CurPtr)) IntEnd = CurPtr;
|
||||||
if (!KeywordEnd && !isalnum(*CurPtr) && *CurPtr != '_') KeywordEnd = CurPtr;
|
if (!KeywordEnd && !isalnum(*CurPtr) && *CurPtr != '_') KeywordEnd = CurPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we stopped due to a colon, this really is a label.
|
// If we stopped due to a colon, this really is a label.
|
||||||
if (*CurPtr == ':') {
|
if (*CurPtr == ':') {
|
||||||
llvmAsmlval.StrVal = new std::string(StartChar-1, CurPtr++);
|
llvmAsmlval.StrVal = new std::string(StartChar-1, CurPtr++);
|
||||||
return LABELSTR;
|
return LABELSTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, this wasn't a label. If this was valid as an integer type,
|
// Otherwise, this wasn't a label. If this was valid as an integer type,
|
||||||
// return it.
|
// return it.
|
||||||
if (IntEnd == 0) IntEnd = CurPtr;
|
if (IntEnd == 0) IntEnd = CurPtr;
|
||||||
if (IntEnd != StartChar) {
|
if (IntEnd != StartChar) {
|
||||||
CurPtr = IntEnd;
|
CurPtr = IntEnd;
|
||||||
uint64_t NumBits = atoull(StartChar, CurPtr);
|
uint64_t NumBits = atoull(StartChar, CurPtr);
|
||||||
if (NumBits < IntegerType::MIN_INT_BITS ||
|
if (NumBits < IntegerType::MIN_INT_BITS ||
|
||||||
NumBits > IntegerType::MAX_INT_BITS) {
|
NumBits > IntegerType::MAX_INT_BITS) {
|
||||||
GenerateError("Bitwidth for integer type out of range!");
|
GenerateError("Bitwidth for integer type out of range!");
|
||||||
return YYERROR;
|
return YYERROR;
|
||||||
@ -423,7 +425,7 @@ int LLLexer::LexIdentifier() {
|
|||||||
llvmAsmlval.PrimType = Ty;
|
llvmAsmlval.PrimType = Ty;
|
||||||
return INTTYPE;
|
return INTTYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, this was a letter sequence. See which keyword this is.
|
// Otherwise, this was a letter sequence. See which keyword this is.
|
||||||
if (KeywordEnd == 0) KeywordEnd = CurPtr;
|
if (KeywordEnd == 0) KeywordEnd = CurPtr;
|
||||||
CurPtr = KeywordEnd;
|
CurPtr = KeywordEnd;
|
||||||
@ -440,7 +442,7 @@ int LLLexer::LexIdentifier() {
|
|||||||
KEYWORD("define", DEFINE);
|
KEYWORD("define", DEFINE);
|
||||||
KEYWORD("global", GLOBAL);
|
KEYWORD("global", GLOBAL);
|
||||||
KEYWORD("constant", CONSTANT);
|
KEYWORD("constant", CONSTANT);
|
||||||
|
|
||||||
KEYWORD("internal", INTERNAL);
|
KEYWORD("internal", INTERNAL);
|
||||||
KEYWORD("linkonce", LINKONCE);
|
KEYWORD("linkonce", LINKONCE);
|
||||||
KEYWORD("weak", WEAK);
|
KEYWORD("weak", WEAK);
|
||||||
@ -470,14 +472,14 @@ int LLLexer::LexIdentifier() {
|
|||||||
KEYWORD("asm", ASM_TOK);
|
KEYWORD("asm", ASM_TOK);
|
||||||
KEYWORD("sideeffect", SIDEEFFECT);
|
KEYWORD("sideeffect", SIDEEFFECT);
|
||||||
KEYWORD("gc", GC);
|
KEYWORD("gc", GC);
|
||||||
|
|
||||||
KEYWORD("cc", CC_TOK);
|
KEYWORD("cc", CC_TOK);
|
||||||
KEYWORD("ccc", CCC_TOK);
|
KEYWORD("ccc", CCC_TOK);
|
||||||
KEYWORD("fastcc", FASTCC_TOK);
|
KEYWORD("fastcc", FASTCC_TOK);
|
||||||
KEYWORD("coldcc", COLDCC_TOK);
|
KEYWORD("coldcc", COLDCC_TOK);
|
||||||
KEYWORD("x86_stdcallcc", X86_STDCALLCC_TOK);
|
KEYWORD("x86_stdcallcc", X86_STDCALLCC_TOK);
|
||||||
KEYWORD("x86_fastcallcc", X86_FASTCALLCC_TOK);
|
KEYWORD("x86_fastcallcc", X86_FASTCALLCC_TOK);
|
||||||
|
|
||||||
KEYWORD("signext", SIGNEXT);
|
KEYWORD("signext", SIGNEXT);
|
||||||
KEYWORD("zeroext", ZEROEXT);
|
KEYWORD("zeroext", ZEROEXT);
|
||||||
KEYWORD("inreg", INREG);
|
KEYWORD("inreg", INREG);
|
||||||
@ -489,7 +491,7 @@ int LLLexer::LexIdentifier() {
|
|||||||
KEYWORD("nest", NEST);
|
KEYWORD("nest", NEST);
|
||||||
KEYWORD("readnone", READNONE);
|
KEYWORD("readnone", READNONE);
|
||||||
KEYWORD("readonly", READONLY);
|
KEYWORD("readonly", READONLY);
|
||||||
|
|
||||||
KEYWORD("type", TYPE);
|
KEYWORD("type", TYPE);
|
||||||
KEYWORD("opaque", OPAQUE);
|
KEYWORD("opaque", OPAQUE);
|
||||||
|
|
||||||
@ -539,7 +541,7 @@ int LLLexer::LexIdentifier() {
|
|||||||
if (JustWhitespaceNewLine(CurPtr))
|
if (JustWhitespaceNewLine(CurPtr))
|
||||||
return ZEROEXT;
|
return ZEROEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keywords for instructions.
|
// Keywords for instructions.
|
||||||
#define INSTKEYWORD(STR, type, Enum, TOK) \
|
#define INSTKEYWORD(STR, type, Enum, TOK) \
|
||||||
if (Len == strlen(STR) && !memcmp(StartChar, STR, strlen(STR))) { \
|
if (Len == strlen(STR) && !memcmp(StartChar, STR, strlen(STR))) { \
|
||||||
@ -596,8 +598,8 @@ int LLLexer::LexIdentifier() {
|
|||||||
INSTKEYWORD("extractelement", OtherOpVal, ExtractElement, EXTRACTELEMENT);
|
INSTKEYWORD("extractelement", OtherOpVal, ExtractElement, EXTRACTELEMENT);
|
||||||
INSTKEYWORD("insertelement", OtherOpVal, InsertElement, INSERTELEMENT);
|
INSTKEYWORD("insertelement", OtherOpVal, InsertElement, INSERTELEMENT);
|
||||||
INSTKEYWORD("shufflevector", OtherOpVal, ShuffleVector, SHUFFLEVECTOR);
|
INSTKEYWORD("shufflevector", OtherOpVal, ShuffleVector, SHUFFLEVECTOR);
|
||||||
#undef INSTKEYWORD
|
#undef INSTKEYWORD
|
||||||
|
|
||||||
// Check for [us]0x[0-9A-Fa-f]+ which are Hexadecimal constant generated by
|
// Check for [us]0x[0-9A-Fa-f]+ which are Hexadecimal constant generated by
|
||||||
// the CFE to avoid forcing it to deal with 64-bit numbers.
|
// the CFE to avoid forcing it to deal with 64-bit numbers.
|
||||||
if ((TokStart[0] == 'u' || TokStart[0] == 's') &&
|
if ((TokStart[0] == 'u' || TokStart[0] == 's') &&
|
||||||
@ -619,13 +621,13 @@ int LLLexer::LexIdentifier() {
|
|||||||
return EUINT64VAL;
|
return EUINT64VAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this is "cc1234", return this as just "cc".
|
// If this is "cc1234", return this as just "cc".
|
||||||
if (TokStart[0] == 'c' && TokStart[1] == 'c') {
|
if (TokStart[0] == 'c' && TokStart[1] == 'c') {
|
||||||
CurPtr = TokStart+2;
|
CurPtr = TokStart+2;
|
||||||
return CC_TOK;
|
return CC_TOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this starts with "call", return it as CALL. This is to support old
|
// If this starts with "call", return it as CALL. This is to support old
|
||||||
// broken .ll files. FIXME: remove this with LLVM 3.0.
|
// broken .ll files. FIXME: remove this with LLVM 3.0.
|
||||||
if (CurPtr-TokStart > 4 && !memcmp(TokStart, "call", 4)) {
|
if (CurPtr-TokStart > 4 && !memcmp(TokStart, "call", 4)) {
|
||||||
@ -633,7 +635,7 @@ int LLLexer::LexIdentifier() {
|
|||||||
llvmAsmlval.OtherOpVal = Instruction::Call;
|
llvmAsmlval.OtherOpVal = Instruction::Call;
|
||||||
return CALL;
|
return CALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally, if this isn't known, return just a single character.
|
// Finally, if this isn't known, return just a single character.
|
||||||
CurPtr = TokStart+1;
|
CurPtr = TokStart+1;
|
||||||
return TokStart[0];
|
return TokStart[0];
|
||||||
@ -648,7 +650,7 @@ int LLLexer::LexIdentifier() {
|
|||||||
/// HexPPC128Constant 0xM[0-9A-Fa-f]+
|
/// HexPPC128Constant 0xM[0-9A-Fa-f]+
|
||||||
int LLLexer::Lex0x() {
|
int LLLexer::Lex0x() {
|
||||||
CurPtr = TokStart + 2;
|
CurPtr = TokStart + 2;
|
||||||
|
|
||||||
char Kind;
|
char Kind;
|
||||||
if (CurPtr[0] >= 'K' && CurPtr[0] <= 'M') {
|
if (CurPtr[0] >= 'K' && CurPtr[0] <= 'M') {
|
||||||
Kind = *CurPtr++;
|
Kind = *CurPtr++;
|
||||||
@ -661,18 +663,18 @@ int LLLexer::Lex0x() {
|
|||||||
CurPtr = TokStart+1;
|
CurPtr = TokStart+1;
|
||||||
return '0';
|
return '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
while (isxdigit(CurPtr[0]))
|
while (isxdigit(CurPtr[0]))
|
||||||
++CurPtr;
|
++CurPtr;
|
||||||
|
|
||||||
if (Kind == 'J') {
|
if (Kind == 'J') {
|
||||||
// HexFPConstant - Floating point constant represented in IEEE format as a
|
// HexFPConstant - Floating point constant represented in IEEE format as a
|
||||||
// hexadecimal number for when exponential notation is not precise enough.
|
// hexadecimal number for when exponential notation is not precise enough.
|
||||||
// Float and double only.
|
// Float and double only.
|
||||||
llvmAsmlval.FPVal = new APFloat(HexToFP(TokStart+2, CurPtr));
|
llvmAsmlval.FPVal = new APFloat(HexToFP(TokStart+2, CurPtr));
|
||||||
return FPVAL;
|
return FPVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t Pair[2];
|
uint64_t Pair[2];
|
||||||
HexToIntPair(TokStart+3, CurPtr, Pair);
|
HexToIntPair(TokStart+3, CurPtr, Pair);
|
||||||
switch (Kind) {
|
switch (Kind) {
|
||||||
@ -710,15 +712,16 @@ int LLLexer::LexDigitOrNegative() {
|
|||||||
CurPtr = End;
|
CurPtr = End;
|
||||||
return LABELSTR;
|
return LABELSTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return CurPtr[-1];
|
return CurPtr[-1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// At this point, it is either a label, int or fp constant.
|
// At this point, it is either a label, int or fp constant.
|
||||||
|
|
||||||
// Skip digits, we have at least one.
|
// Skip digits, we have at least one.
|
||||||
for (; isdigit(CurPtr[0]); ++CurPtr);
|
for (; isdigit(CurPtr[0]); ++CurPtr)
|
||||||
|
/*empty*/;
|
||||||
|
|
||||||
// Check to see if this really is a label afterall, e.g. "-1:".
|
// Check to see if this really is a label afterall, e.g. "-1:".
|
||||||
if (isLabelChar(CurPtr[0]) || CurPtr[0] == ':') {
|
if (isLabelChar(CurPtr[0]) || CurPtr[0] == ':') {
|
||||||
if (const char *End = isLabelTail(CurPtr)) {
|
if (const char *End = isLabelTail(CurPtr)) {
|
||||||
@ -727,7 +730,7 @@ int LLLexer::LexDigitOrNegative() {
|
|||||||
return LABELSTR;
|
return LABELSTR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the next character is a '.', then it is a fp value, otherwise its
|
// If the next character is a '.', then it is a fp value, otherwise its
|
||||||
// integer.
|
// integer.
|
||||||
if (CurPtr[0] != '.') {
|
if (CurPtr[0] != '.') {
|
||||||
@ -753,7 +756,7 @@ int LLLexer::LexDigitOrNegative() {
|
|||||||
Tmp.trunc(activeBits);
|
Tmp.trunc(activeBits);
|
||||||
if (Tmp.getBitWidth() > 64) {
|
if (Tmp.getBitWidth() > 64) {
|
||||||
llvmAsmlval.APIntVal = new APInt(Tmp);
|
llvmAsmlval.APIntVal = new APInt(Tmp);
|
||||||
return EUAPINTVAL;
|
return EUAPINTVAL;
|
||||||
} else {
|
} else {
|
||||||
llvmAsmlval.UInt64Val = Tmp.getZExtValue();
|
llvmAsmlval.UInt64Val = Tmp.getZExtValue();
|
||||||
return EUINT64VAL;
|
return EUINT64VAL;
|
||||||
@ -762,20 +765,20 @@ int LLLexer::LexDigitOrNegative() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
++CurPtr;
|
++CurPtr;
|
||||||
|
|
||||||
// Skip over [0-9]*([eE][-+]?[0-9]+)?
|
// Skip over [0-9]*([eE][-+]?[0-9]+)?
|
||||||
while (isdigit(CurPtr[0])) ++CurPtr;
|
while (isdigit(CurPtr[0])) ++CurPtr;
|
||||||
|
|
||||||
if (CurPtr[0] == 'e' || CurPtr[0] == 'E') {
|
if (CurPtr[0] == 'e' || CurPtr[0] == 'E') {
|
||||||
if (isdigit(CurPtr[1]) ||
|
if (isdigit(CurPtr[1]) ||
|
||||||
((CurPtr[1] == '-' || CurPtr[1] == '+') && isdigit(CurPtr[2]))) {
|
((CurPtr[1] == '-' || CurPtr[1] == '+') && isdigit(CurPtr[2]))) {
|
||||||
CurPtr += 2;
|
CurPtr += 2;
|
||||||
while (isdigit(CurPtr[0])) ++CurPtr;
|
while (isdigit(CurPtr[0])) ++CurPtr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
llvmAsmlval.FPVal = new APFloat(atof(TokStart));
|
llvmAsmlval.FPVal = new APFloat(atof(TokStart));
|
||||||
return FPVAL;
|
return FPVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// FPConstant [-+]?[0-9]+[.][0-9]*([eE][-+]?[0-9]+)?
|
/// FPConstant [-+]?[0-9]+[.][0-9]*([eE][-+]?[0-9]+)?
|
||||||
@ -784,31 +787,32 @@ int LLLexer::LexPositive() {
|
|||||||
// label.
|
// label.
|
||||||
if (!isdigit(CurPtr[0]))
|
if (!isdigit(CurPtr[0]))
|
||||||
return CurPtr[-1];
|
return CurPtr[-1];
|
||||||
|
|
||||||
// Skip digits.
|
// Skip digits.
|
||||||
for (++CurPtr; isdigit(CurPtr[0]); ++CurPtr);
|
for (++CurPtr; isdigit(CurPtr[0]); ++CurPtr)
|
||||||
|
/*empty*/;
|
||||||
|
|
||||||
// At this point, we need a '.'.
|
// At this point, we need a '.'.
|
||||||
if (CurPtr[0] != '.') {
|
if (CurPtr[0] != '.') {
|
||||||
CurPtr = TokStart+1;
|
CurPtr = TokStart+1;
|
||||||
return TokStart[0];
|
return TokStart[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
++CurPtr;
|
++CurPtr;
|
||||||
|
|
||||||
// Skip over [0-9]*([eE][-+]?[0-9]+)?
|
// Skip over [0-9]*([eE][-+]?[0-9]+)?
|
||||||
while (isdigit(CurPtr[0])) ++CurPtr;
|
while (isdigit(CurPtr[0])) ++CurPtr;
|
||||||
|
|
||||||
if (CurPtr[0] == 'e' || CurPtr[0] == 'E') {
|
if (CurPtr[0] == 'e' || CurPtr[0] == 'E') {
|
||||||
if (isdigit(CurPtr[1]) ||
|
if (isdigit(CurPtr[1]) ||
|
||||||
((CurPtr[1] == '-' || CurPtr[1] == '+') && isdigit(CurPtr[2]))) {
|
((CurPtr[1] == '-' || CurPtr[1] == '+') && isdigit(CurPtr[2]))) {
|
||||||
CurPtr += 2;
|
CurPtr += 2;
|
||||||
while (isdigit(CurPtr[0])) ++CurPtr;
|
while (isdigit(CurPtr[0])) ++CurPtr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
llvmAsmlval.FPVal = new APFloat(atof(TokStart));
|
llvmAsmlval.FPVal = new APFloat(atof(TokStart));
|
||||||
return FPVAL;
|
return FPVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user