summaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCParser/COFFAsmParser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/MC/MCParser/COFFAsmParser.cpp')
-rw-r--r--llvm/lib/MC/MCParser/COFFAsmParser.cpp66
1 files changed, 22 insertions, 44 deletions
diff --git a/llvm/lib/MC/MCParser/COFFAsmParser.cpp b/llvm/lib/MC/MCParser/COFFAsmParser.cpp
index 9fb17488a9e9..5dd79946d877 100644
--- a/llvm/lib/MC/MCParser/COFFAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/COFFAsmParser.cpp
@@ -293,13 +293,11 @@ bool COFFAsmParser::parseDirectiveSymbolAttribute(StringRef Directive, SMLoc) {
assert(Attr != MCSA_Invalid && "unexpected symbol attribute directive!");
if (getLexer().isNot(AsmToken::EndOfStatement)) {
while (true) {
- StringRef Name;
+ MCSymbol *Sym;
- if (getParser().parseIdentifier(Name))
+ if (getParser().parseSymbol(Sym))
return TokError("expected identifier in directive");
- MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
-
getStreamer().emitSymbolAttribute(Sym, Attr);
if (getLexer().is(AsmToken::EndOfStatement))
@@ -450,13 +448,11 @@ bool COFFAsmParser::parseDirectivePopSection(StringRef, SMLoc) {
}
bool COFFAsmParser::parseDirectiveDef(StringRef, SMLoc) {
- StringRef SymbolName;
+ MCSymbol *Sym;
- if (getParser().parseIdentifier(SymbolName))
+ if (getParser().parseSymbol(Sym))
return TokError("expected identifier in directive");
- MCSymbol *Sym = getContext().getOrCreateSymbol(SymbolName);
-
getStreamer().beginCOFFSymbolDef(Sym);
Lex();
@@ -496,8 +492,8 @@ bool COFFAsmParser::parseDirectiveEndef(StringRef, SMLoc) {
}
bool COFFAsmParser::parseDirectiveSecRel32(StringRef, SMLoc) {
- StringRef SymbolID;
- if (getParser().parseIdentifier(SymbolID))
+ MCSymbol *Symbol;
+ if (getParser().parseSymbol(Symbol))
return TokError("expected identifier in directive");
int64_t Offset = 0;
@@ -517,8 +513,6 @@ bool COFFAsmParser::parseDirectiveSecRel32(StringRef, SMLoc) {
"invalid '.secrel32' directive offset, can't be less "
"than zero or greater than std::numeric_limits<uint32_t>::max()");
- MCSymbol *Symbol = getContext().getOrCreateSymbol(SymbolID);
-
Lex();
getStreamer().emitCOFFSecRel32(Symbol, Offset);
return false;
@@ -526,8 +520,8 @@ bool COFFAsmParser::parseDirectiveSecRel32(StringRef, SMLoc) {
bool COFFAsmParser::parseDirectiveRVA(StringRef, SMLoc) {
auto parseOp = [&]() -> bool {
- StringRef SymbolID;
- if (getParser().parseIdentifier(SymbolID))
+ MCSymbol *Symbol;
+ if (getParser().parseSymbol(Symbol))
return TokError("expected identifier in directive");
int64_t Offset = 0;
@@ -544,8 +538,6 @@ bool COFFAsmParser::parseDirectiveRVA(StringRef, SMLoc) {
"than -2147483648 or greater than "
"2147483647");
- MCSymbol *Symbol = getContext().getOrCreateSymbol(SymbolID);
-
getStreamer().emitCOFFImgRel32(Symbol, Offset);
return false;
};
@@ -556,75 +548,65 @@ bool COFFAsmParser::parseDirectiveRVA(StringRef, SMLoc) {
}
bool COFFAsmParser::parseDirectiveSafeSEH(StringRef, SMLoc) {
- StringRef SymbolID;
- if (getParser().parseIdentifier(SymbolID))
+ MCSymbol *Symbol;
+ if (getParser().parseSymbol(Symbol))
return TokError("expected identifier in directive");
if (getLexer().isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in directive");
- MCSymbol *Symbol = getContext().getOrCreateSymbol(SymbolID);
-
Lex();
getStreamer().emitCOFFSafeSEH(Symbol);
return false;
}
bool COFFAsmParser::parseDirectiveSecIdx(StringRef, SMLoc) {
- StringRef SymbolID;
- if (getParser().parseIdentifier(SymbolID))
+ MCSymbol *Symbol;
+ if (getParser().parseSymbol(Symbol))
return TokError("expected identifier in directive");
if (getLexer().isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in directive");
- MCSymbol *Symbol = getContext().getOrCreateSymbol(SymbolID);
-
Lex();
getStreamer().emitCOFFSectionIndex(Symbol);
return false;
}
bool COFFAsmParser::parseDirectiveSymIdx(StringRef, SMLoc) {
- StringRef SymbolID;
- if (getParser().parseIdentifier(SymbolID))
+ MCSymbol *Symbol;
+ if (getParser().parseSymbol(Symbol))
return TokError("expected identifier in directive");
if (getLexer().isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in directive");
- MCSymbol *Symbol = getContext().getOrCreateSymbol(SymbolID);
-
Lex();
getStreamer().emitCOFFSymbolIndex(Symbol);
return false;
}
bool COFFAsmParser::parseDirectiveSecNum(StringRef, SMLoc) {
- StringRef SymbolID;
- if (getParser().parseIdentifier(SymbolID))
+ MCSymbol *Symbol;
+ if (getParser().parseSymbol(Symbol))
return TokError("expected identifier in directive");
if (getLexer().isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in directive");
- MCSymbol *Symbol = getContext().getOrCreateSymbol(SymbolID);
-
Lex();
getStreamer().emitCOFFSecNumber(Symbol);
return false;
}
bool COFFAsmParser::parseDirectiveSecOffset(StringRef, SMLoc) {
- StringRef SymbolID;
- if (getParser().parseIdentifier(SymbolID))
+ MCSymbol *Symbol;
+ if (getParser().parseSymbol(Symbol))
return TokError("expected identifier in directive");
if (getLexer().isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in directive");
- MCSymbol *Symbol = getContext().getOrCreateSymbol(SymbolID);
-
Lex();
getStreamer().emitCOFFSecOffset(Symbol);
return false;
@@ -679,15 +661,13 @@ bool COFFAsmParser::parseDirectiveLinkOnce(StringRef, SMLoc Loc) {
}
bool COFFAsmParser::parseSEHDirectiveStartProc(StringRef, SMLoc Loc) {
- StringRef SymbolID;
- if (getParser().parseIdentifier(SymbolID))
+ MCSymbol *Symbol;
+ if (getParser().parseSymbol(Symbol))
return true;
if (getLexer().isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in directive");
- MCSymbol *Symbol = getContext().getOrCreateSymbol(SymbolID);
-
Lex();
getStreamer().emitWinCFIStartProc(Symbol, Loc);
return false;
@@ -718,8 +698,8 @@ bool COFFAsmParser::parseSEHDirectiveEndChained(StringRef, SMLoc Loc) {
}
bool COFFAsmParser::parseSEHDirectiveHandler(StringRef, SMLoc Loc) {
- StringRef SymbolID;
- if (getParser().parseIdentifier(SymbolID))
+ MCSymbol *handler;
+ if (getParser().parseSymbol(handler))
return true;
if (getLexer().isNot(AsmToken::Comma))
@@ -736,8 +716,6 @@ bool COFFAsmParser::parseSEHDirectiveHandler(StringRef, SMLoc Loc) {
if (getLexer().isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in directive");
- MCSymbol *handler = getContext().getOrCreateSymbol(SymbolID);
-
Lex();
getStreamer().emitWinEHHandler(handler, unwind, except, Loc);
return false;