return false;
}
+MCSymbol *AsmParser::CreateSymbol(StringRef Name) {
+ if (MCSymbol *S = Ctx.LookupSymbol(Name))
+ return S;
+
+ // If the label starts with L it is an assembler temporary label.
+ if (Name.startswith("L"))
+ return Ctx.CreateTemporarySymbol(Name);
+
+ return Ctx.CreateSymbol(Name);
+}
+
/// ParsePrimaryExpr - Parse a primary expression and return it.
/// primaryexpr ::= (parenexpr
/// primaryexpr ::= symbol
case AsmToken::Identifier: {
// This is a label, this should be parsed as part of an expression, to
// handle things like LFOO+4.
- MCSymbol *Sym = Ctx.GetOrCreateSymbol(Lexer.getTok().getIdentifier());
+ MCSymbol *Sym = CreateSymbol(Lexer.getTok().getIdentifier());
Res = new AsmSymbolRefExpr(Sym);
Lexer.Lex(); // Eat identifier.
// FIXME: Diagnostics. Note the location of the definition as a label.
// FIXME: This doesn't diagnose assignment to a symbol which has been
// implicitly marked as external.
- MCSymbol *Sym = Ctx.GetOrCreateSymbol(IDVal);
+ MCSymbol *Sym = CreateSymbol(IDVal);
if (!Sym->isUndefined())
return Error(IDLoc, "invalid symbol redefinition");
- // Since we saw a label, create a symbol and emit it.
- // FIXME: If the label starts with L it is an assembler temporary label.
- // Why does the client of this api need to know this?
+ // Emit the label.
Out.EmitLabel(Sym);
return ParseStatement();
// FIXME: Diagnostics. Note the location of the definition as a label.
// FIXME: Handle '.'.
// FIXME: Diagnose assignment to protected identifier (e.g., register name).
- MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name);
+ MCSymbol *Sym = CreateSymbol(Name);
if (!Sym->isUndefined() && !Sym->isAbsolute())
return Error(EqualLoc, "symbol has already been defined");
if (ParseIdentifier(Name))
return TokError("expected identifier in directive");
- MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name);
+ MCSymbol *Sym = CreateSymbol(Name);
Out.EmitSymbolAttribute(Sym, Attr);
return TokError("expected identifier in directive");
// Handle the identifier as the key symbol.
- MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name);
+ MCSymbol *Sym = CreateSymbol(Name);
if (Lexer.isNot(AsmToken::Comma))
return TokError("unexpected token in '.desc' directive");
return TokError("expected identifier in directive");
// Handle the identifier as the key symbol.
- MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name);
+ MCSymbol *Sym = CreateSymbol(Name);
if (Lexer.isNot(AsmToken::Comma))
return TokError("unexpected token in directive");
// handle the identifier as the key symbol.
SMLoc IDLoc = Lexer.getLoc();
- MCSymbol *Sym = Ctx.GetOrCreateSymbol(Lexer.getTok().getString());
+ MCSymbol *Sym = CreateSymbol(Lexer.getTok().getString());
Lexer.Lex();
if (Lexer.isNot(AsmToken::Comma))
return TokError("expected identifier in directive");
// Handle the identifier as the key symbol.
- MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name);
+ MCSymbol *Sym = CreateSymbol(Name);
if (Lexer.isNot(AsmToken::Comma))
return TokError("unexpected token in '.lsym' directive");