summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-08-22 07:22:36 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-08-22 07:22:36 +0000
commit8906ff1b9dfde28f1ff00706643ca10843b26e01 (patch)
tree9cd4a02e407a6ac0751c459bb5327f1f6f3cc07e /tools
parent66aa9b1c2ff5ba278dd35d720e0ed38bccca3a8e (diff)
downloadllvm-8906ff1b9dfde28f1ff00706643ca10843b26e01.tar.gz
llvm-8906ff1b9dfde28f1ff00706643ca10843b26e01.tar.bz2
llvm-8906ff1b9dfde28f1ff00706643ca10843b26e01.tar.xz
llvm-mc: Clean up some handling of symbol/section association to be more correct
(external was really undefined and there wasn't an explicit representation for absolute symbols). - This still needs some cleanup to how the absolute "pseudo" section is dealt with, but I haven't figured out the nicest approach yet. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79733 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/llvm-mc/AsmParser.cpp26
1 files changed, 5 insertions, 21 deletions
diff --git a/tools/llvm-mc/AsmParser.cpp b/tools/llvm-mc/AsmParser.cpp
index 1978121297..d92d514f8a 100644
--- a/tools/llvm-mc/AsmParser.cpp
+++ b/tools/llvm-mc/AsmParser.cpp
@@ -149,10 +149,6 @@ bool AsmParser::ParsePrimaryExpr(AsmExpr *&Res) {
// 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());
-
- // If this is use of an undefined symbol then mark it external.
- if (!Sym->getSection() && !Ctx.GetSymbolValue(Sym))
- Sym->setExternal(true);
Res = new AsmSymbolRefExpr(Sym);
Lexer.Lex(); // Eat identifier.
@@ -376,10 +372,8 @@ bool AsmParser::ParseStatement() {
// FIXME: This doesn't diagnose assignment to a symbol which has been
// implicitly marked as external.
MCSymbol *Sym = Ctx.GetOrCreateSymbol(IDVal);
- if (Sym->getSection())
+ if (!Sym->isUndefined())
return Error(IDLoc, "invalid symbol redefinition");
- if (Ctx.GetSymbolValue(Sym))
- return Error(IDLoc, "symbol already used as assembler variable");
// Since we saw a label, create a symbol and emit it.
// FIXME: If the label starts with L it is an assembler temporary label.
@@ -687,15 +681,11 @@ bool AsmParser::ParseAssignment(const StringRef &Name, bool IsDotSet) {
// Diagnose assignment to a label.
//
// 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.
// FIXME: Handle '.'.
// FIXME: Diagnose assignment to protected identifier (e.g., register name).
MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name);
- if (Sym->getSection())
- return Error(EqualLoc, "invalid assignment to symbol emitted as a label");
- if (Sym->isExternal())
- return Error(EqualLoc, "invalid assignment to external symbol");
+ if (!Sym->isUndefined() && !Sym->isAbsolute())
+ return Error(EqualLoc, "symbol has already been defined");
// Do the assignment.
Out.EmitAssignment(Sym, Value, IsDotSet);
@@ -1117,10 +1107,6 @@ bool AsmParser::ParseDirectiveSymbolAttribute(MCStreamer::SymbolAttr Attr) {
MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name);
- // If this is use of an undefined symbol then mark it external.
- if (!Sym->getSection() && !Ctx.GetSymbolValue(Sym))
- Sym->setExternal(true);
-
Out.EmitSymbolAttribute(Sym, Attr);
if (Lexer.is(AsmToken::EndOfStatement))
@@ -1213,8 +1199,7 @@ bool AsmParser::ParseDirectiveComm(bool IsLocal) {
return Error(Pow2AlignmentLoc, "invalid '.comm' or '.lcomm' directive "
"alignment, can't be less than zero");
- // TODO: Symbol must be undefined or it is a error to re-defined the symbol
- if (Sym->getSection() || Ctx.GetSymbolValue(Sym))
+ if (!Sym->isUndefined())
return Error(IDLoc, "invalid symbol redefinition");
// Create the Symbol as a common or local common with Size and Pow2Alignment
@@ -1305,8 +1290,7 @@ bool AsmParser::ParseDirectiveDarwinZerofill() {
return Error(Pow2AlignmentLoc, "invalid '.zerofill' directive alignment, "
"can't be less than zero");
- // TODO: Symbol must be undefined or it is a error to re-defined the symbol
- if (Sym->getSection() || Ctx.GetSymbolValue(Sym))
+ if (!Sym->isUndefined())
return Error(IDLoc, "invalid symbol redefinition");
// FIXME: Arch specific.