aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCParser/AsmLexer.cpp
diff options
context:
space:
mode:
authorDavid Peixotto <dpeixott@codeaurora.org>2013-12-06 20:35:58 +0000
committerDavid Peixotto <dpeixott@codeaurora.org>2013-12-06 20:35:58 +0000
commit2cdc56d26b80f292f0ea526fc26b6fcc0708b285 (patch)
treefa423bb1422d8d6cab325526bb5ec72a53a28d91 /llvm/lib/MC/MCParser/AsmLexer.cpp
parent3e325d7490a0a0645a147db98a107d41f65270fd (diff)
downloadllvm-2cdc56d26b80f292f0ea526fc26b6fcc0708b285.zip
llvm-2cdc56d26b80f292f0ea526fc26b6fcc0708b285.tar.gz
llvm-2cdc56d26b80f292f0ea526fc26b6fcc0708b285.tar.bz2
Integrated assembler incorrectly lexes ARM-style comments
The integrated assembler fails to properly lex arm comments when they are adjacent to an identifier in the input stream. The reason is that the arm comment symbol '@' is also used as symbol variant in other assembly languages so when lexing an identifier it allows the '@' symbol as part of the identifier. Example: $ cat comment.s foo: add r0, r0@got to parse this as a comment $ llvm-mc -triple armv7 comment.s comment.s:4:18: error: unexpected token in argument list add r0, r0@got to parse this as a comment ^ This should be parsed as correctly as `add r0, r0`. This commit modifes the assembly lexer to not include the '@' symbol in identifiers when lexing for targets that use '@' for comments. llvm-svn: 196607
Diffstat (limited to 'llvm/lib/MC/MCParser/AsmLexer.cpp')
-rw-r--r--llvm/lib/MC/MCParser/AsmLexer.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/llvm/lib/MC/MCParser/AsmLexer.cpp b/llvm/lib/MC/MCParser/AsmLexer.cpp
index b49dd01..a066e64 100644
--- a/llvm/lib/MC/MCParser/AsmLexer.cpp
+++ b/llvm/lib/MC/MCParser/AsmLexer.cpp
@@ -139,20 +139,23 @@ AsmToken AsmLexer::LexHexFloatLiteral(bool NoIntDigits) {
}
/// LexIdentifier: [a-zA-Z_.][a-zA-Z0-9_$.@?]*
-static bool IsIdentifierChar(char c) {
- return isalnum(c) || c == '_' || c == '$' || c == '.' || c == '@' || c == '?';
+static bool IsIdentifierChar(char c, bool AllowAt) {
+ return isalnum(c) || c == '_' || c == '$' || c == '.' ||
+ (c == '@' && AllowAt) || c == '?';
}
AsmToken AsmLexer::LexIdentifier() {
+ bool AllowAtInIdentifier = !StringRef(MAI.getCommentString()).startswith("@");
// Check for floating point literals.
if (CurPtr[-1] == '.' && isdigit(*CurPtr)) {
// Disambiguate a .1243foo identifier from a floating literal.
while (isdigit(*CurPtr))
++CurPtr;
- if (*CurPtr == 'e' || *CurPtr == 'E' || !IsIdentifierChar(*CurPtr))
+ if (*CurPtr == 'e' || *CurPtr == 'E' ||
+ !IsIdentifierChar(*CurPtr, AllowAtInIdentifier))
return LexFloatLiteral();
}
- while (IsIdentifierChar(*CurPtr))
+ while (IsIdentifierChar(*CurPtr, AllowAtInIdentifier))
++CurPtr;
// Handle . as a special case.