1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

AsmParser: More generic support for integer type suffices.

For integer constants, allow 'L', 'UL' as well as 'ULL' and 'LL'. This provides
better support for shared headers between .s and .c files that define bunches
of constant values.

rdar://9321056

llvm-svn: 176118
This commit is contained in:
Jim Grosbach 2013-02-26 20:17:10 +00:00
parent 1fe2ec2235
commit 45dec6440d
2 changed files with 15 additions and 6 deletions

View File

@ -156,10 +156,13 @@ AsmToken AsmLexer::LexLineComment() {
} }
static void SkipIgnoredIntegerSuffix(const char *&CurPtr) { static void SkipIgnoredIntegerSuffix(const char *&CurPtr) {
if (CurPtr[0] == 'L' && CurPtr[1] == 'L') // Skip ULL, UL, U, L and LL suffices.
CurPtr += 2; if (CurPtr[0] == 'U')
if (CurPtr[0] == 'U' && CurPtr[1] == 'L' && CurPtr[2] == 'L') ++CurPtr;
CurPtr += 3; if (CurPtr[0] == 'L')
++CurPtr;
if (CurPtr[0] == 'L')
++CurPtr;
} }
// Look ahead to search for first non-hex digit, if it's [hH], then we treat the // Look ahead to search for first non-hex digit, if it's [hH], then we treat the
@ -220,8 +223,8 @@ AsmToken AsmLexer::LexDigit() {
if (Radix == 2 || Radix == 16) if (Radix == 2 || Radix == 16)
++CurPtr; ++CurPtr;
// The darwin/x86 (and x86-64) assembler accepts and ignores ULL and LL // The darwin/x86 (and x86-64) assembler accepts and ignores type
// suffixes on integer literals. // suffices on integer literals.
SkipIgnoredIntegerSuffix(CurPtr); SkipIgnoredIntegerSuffix(CurPtr);
return AsmToken(AsmToken::Integer, Result, Value); return AsmToken(AsmToken::Integer, Result, Value);

View File

@ -63,3 +63,9 @@ TEST7:
# CHECK-NEXT: .byte 2 # CHECK-NEXT: .byte 2
# CHECK-NEXT: .byte 3 # CHECK-NEXT: .byte 3
# CHECK-NEXT: .byte 4 # CHECK-NEXT: .byte 4
TEST8:
.long 0x200000UL+1
.long 0x200000L+1
# CHECK: .long 2097153
# CHECK: .long 2097153