MC/AsmParser: Change ParseExpression to use ParseIdentifier(), to support
authorDaniel Dunbar <daniel@zuster.org>
Tue, 24 Aug 2010 19:13:42 +0000 (19:13 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 24 Aug 2010 19:13:42 +0000 (19:13 +0000)
dollars in identifiers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111946 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MCParser/AsmParser.cpp
test/MC/AsmParser/dollars-in-identifiers.s

index 6d4b96098aeec2e83c5fe3692d0891d75ea5a369..747b0097e1ec1fff970b3f2ef17d242bbba98403 100644 (file)
@@ -449,10 +449,17 @@ bool AsmParser::ParsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) {
       return true;
     Res = MCUnaryExpr::CreateLNot(Res, getContext());
     return false;
+  case AsmToken::Dollar:
   case AsmToken::String:
   case AsmToken::Identifier: {
+    EndLoc = Lexer.getLoc();
+
+    StringRef Identifier;
+    if (ParseIdentifier(Identifier))
+      return false;
+
     // This is a symbol reference.
-    std::pair<StringRef, StringRef> Split = getTok().getIdentifier().split('@');
+    std::pair<StringRef, StringRef> Split = Identifier.split('@');
     MCSymbol *Sym = getContext().GetOrCreateSymbol(Split.first);
 
     // Mark the symbol as used in an expression.
@@ -460,12 +467,9 @@ bool AsmParser::ParsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) {
 
     // Lookup the symbol variant if used.
     MCSymbolRefExpr::VariantKind Variant = MCSymbolRefExpr::VK_None;
-    if (Split.first.size() != getTok().getIdentifier().size())
+    if (Split.first.size() != Identifier.size())
       Variant = MCSymbolRefExpr::getVariantKindForName(Split.second);
 
-    EndLoc = Lexer.getLoc();
-    Lex(); // Eat identifier.
-
     // If this is an absolute variable reference, substitute it now to preserve
     // semantics in the face of reassignment.
     if (Sym->isVariable() && isa<MCConstantExpr>(Sym->getVariableValue())) {
index 30e66af75a84e8482ebda5d3054a6889c3bae5db..e56959062ad9d9e0ee7c7cbfb2aac026b3acac98 100644 (file)
@@ -3,3 +3,5 @@
 
 // CHECK: .globl $foo
 .globl $foo
+// CHECK: .long ($foo)
+.long ($foo)