summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCParser/AsmParser.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-08-24 18:12:12 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-08-24 18:12:12 +0000
commit3b96ffdac1998ac3df6b0b61c8dfba8df057ad88 (patch)
tree2f5a2c0559b3b851fe9ae1ed1e4adb9c3f9a412c /llvm/lib/MC/MCParser/AsmParser.cpp
parente06c8137e0a0ac58ea83583ac59351b4aa8bb9f9 (diff)
downloadbcm5719-llvm-3b96ffdac1998ac3df6b0b61c8dfba8df057ad88.tar.gz
bcm5719-llvm-3b96ffdac1998ac3df6b0b61c8dfba8df057ad88.zip
MC/Parser: Accept leading dollar signs in identifiers.
- Implemented by manually splicing the tokens. If this turns out to be problematically platform specific, a more elegant solution would be to implement some context dependent lexing support. llvm-svn: 111934
Diffstat (limited to 'llvm/lib/MC/MCParser/AsmParser.cpp')
-rw-r--r--llvm/lib/MC/MCParser/AsmParser.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp
index 87a4a886bc8..6d4b96098ae 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -1127,6 +1127,30 @@ bool AsmParser::ParseAssignment(StringRef Name) {
/// ::= identifier
/// ::= string
bool AsmParser::ParseIdentifier(StringRef &Res) {
+ // The assembler has relaxed rules for accepting identifiers, in particular we
+ // allow things like '.globl $foo', which would normally be separate
+ // tokens. At this level, we have already lexed so we cannot (currently)
+ // handle this as a context dependent token, instead we detect adjacent tokens
+ // and return the combined identifier.
+ if (Lexer.is(AsmToken::Dollar)) {
+ SMLoc DollarLoc = getLexer().getLoc();
+
+ // Consume the dollar sign, and check for a following identifier.
+ Lex();
+ if (Lexer.isNot(AsmToken::Identifier))
+ return true;
+
+ // We have a '$' followed by an identifier, make sure they are adjacent.
+ if (DollarLoc.getPointer() + 1 != getTok().getLoc().getPointer())
+ return true;
+
+ // Construct the joined identifier and consume the token.
+ Res = StringRef(DollarLoc.getPointer(),
+ getTok().getIdentifier().size() + 1);
+ Lex();
+ return false;
+ }
+
if (Lexer.isNot(AsmToken::Identifier) &&
Lexer.isNot(AsmToken::String))
return true;
OpenPOWER on IntegriCloud