-
Couldn't load subscription status.
- Fork 15k
[MC] Add parseSymbol() helper (NFC) #158106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This combined parseIdentifier() + getOrCreateSymbol(). This should make it a bit easier if we want to change the parseIdentifier() API.
|
@llvm/pr-subscribers-llvm-mc Author: Nikita Popov (nikic) ChangesThis combines parseIdentifier() + getOrCreateSymbol(). This should make it a bit easier if we want to change the parseIdentifier() API. Patch is 25.47 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/158106.diff 9 Files Affected:
diff --git a/llvm/include/llvm/MC/MCParser/MCAsmParser.h b/llvm/include/llvm/MC/MCParser/MCAsmParser.h
index cb9bd5c600d52..e3f44a08db641 100644
--- a/llvm/include/llvm/MC/MCParser/MCAsmParser.h
+++ b/llvm/include/llvm/MC/MCParser/MCAsmParser.h
@@ -279,6 +279,9 @@ class LLVM_ABI MCAsmParser {
/// Res to the identifier contents.
virtual bool parseIdentifier(StringRef &Res) = 0;
+ /// Parse identifier and get or create symbol for it.
+ bool parseSymbol(MCSymbol *&Res);
+
/// Parse up to the end of statement and return the contents from the
/// current token until the end of the statement; the current token on exit
/// will be either the EndOfStatement or EOF.
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp
index fb183a10b3d37..cec2afea9a70b 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -3876,20 +3876,17 @@ bool AsmParser::parseDirectiveCVLoc() {
/// ::= .cv_linetable FunctionId, FnStart, FnEnd
bool AsmParser::parseDirectiveCVLinetable() {
int64_t FunctionId;
- StringRef FnStartName, FnEndName;
+ MCSymbol *FnStartSym, *FnEndSym;
SMLoc Loc = getTok().getLoc();
if (parseCVFunctionId(FunctionId, ".cv_linetable") || parseComma() ||
parseTokenLoc(Loc) ||
- check(parseIdentifier(FnStartName), Loc,
+ check(parseSymbol(FnStartSym), Loc,
"expected identifier in directive") ||
parseComma() || parseTokenLoc(Loc) ||
- check(parseIdentifier(FnEndName), Loc,
+ check(parseSymbol(FnEndSym), Loc,
"expected identifier in directive"))
return true;
- MCSymbol *FnStartSym = getContext().getOrCreateSymbol(FnStartName);
- MCSymbol *FnEndSym = getContext().getOrCreateSymbol(FnEndName);
-
getStreamer().emitCVLinetableDirective(FunctionId, FnStartSym, FnEndSym);
return false;
}
@@ -3898,7 +3895,7 @@ bool AsmParser::parseDirectiveCVLinetable() {
/// ::= .cv_inline_linetable PrimaryFunctionId FileId LineNum FnStart FnEnd
bool AsmParser::parseDirectiveCVInlineLinetable() {
int64_t PrimaryFunctionId, SourceFileId, SourceLineNum;
- StringRef FnStartName, FnEndName;
+ MCSymbol *FnStartSym, *FnEndSym;
SMLoc Loc = getTok().getLoc();
if (parseCVFunctionId(PrimaryFunctionId, ".cv_inline_linetable") ||
parseTokenLoc(Loc) ||
@@ -3908,16 +3905,14 @@ bool AsmParser::parseDirectiveCVInlineLinetable() {
parseIntToken(SourceLineNum, "expected SourceLineNum") ||
check(SourceLineNum < 0, Loc, "Line number less than zero") ||
parseTokenLoc(Loc) ||
- check(parseIdentifier(FnStartName), Loc, "expected identifier") ||
+ check(parseSymbol(FnStartSym), Loc, "expected identifier") ||
parseTokenLoc(Loc) ||
- check(parseIdentifier(FnEndName), Loc, "expected identifier"))
+ check(parseSymbol(FnEndSym), Loc, "expected identifier"))
return true;
if (parseEOL())
return true;
- MCSymbol *FnStartSym = getContext().getOrCreateSymbol(FnStartName);
- MCSymbol *FnEndSym = getContext().getOrCreateSymbol(FnEndName);
getStreamer().emitCVInlineLinetableDirective(PrimaryFunctionId, SourceFileId,
SourceLineNum, FnStartSym,
FnEndSym);
@@ -3938,16 +3933,14 @@ bool AsmParser::parseDirectiveCVDefRange() {
std::vector<std::pair<const MCSymbol *, const MCSymbol *>> Ranges;
while (getLexer().is(AsmToken::Identifier)) {
Loc = getLexer().getLoc();
- StringRef GapStartName;
- if (parseIdentifier(GapStartName))
+ MCSymbol *GapStartSym;
+ if (parseSymbol(GapStartSym))
return Error(Loc, "expected identifier in directive");
- MCSymbol *GapStartSym = getContext().getOrCreateSymbol(GapStartName);
Loc = getLexer().getLoc();
- StringRef GapEndName;
- if (parseIdentifier(GapEndName))
+ MCSymbol *GapEndSym;
+ if (parseSymbol(GapEndSym))
return Error(Loc, "expected identifier in directive");
- MCSymbol *GapEndSym = getContext().getOrCreateSymbol(GapEndName);
Ranges.push_back({GapStartSym, GapEndSym});
}
@@ -4084,12 +4077,11 @@ bool AsmParser::parseDirectiveCVFileChecksumOffset() {
/// ::= .cv_fpo_data procsym
bool AsmParser::parseDirectiveCVFPOData() {
SMLoc DirLoc = getLexer().getLoc();
- StringRef ProcName;
- if (parseIdentifier(ProcName))
+ MCSymbol *ProcSym;
+ if (parseSymbol(ProcSym))
return TokError("expected symbol name");
if (parseEOL())
return true;
- MCSymbol *ProcSym = getContext().getOrCreateSymbol(ProcName);
getStreamer().emitCVFPOData(ProcSym, DirLoc);
return false;
}
@@ -4311,15 +4303,13 @@ bool AsmParser::parseDirectiveCFIPersonalityOrLsda(bool IsPersonality) {
if (Encoding == dwarf::DW_EH_PE_omit)
return false;
- StringRef Name;
+ MCSymbol *Sym;
if (check(!isValidEncoding(Encoding), "unsupported encoding.") ||
parseComma() ||
- check(parseIdentifier(Name), "expected identifier in directive") ||
+ check(parseSymbol(Sym), "expected identifier in directive") ||
parseEOL())
return true;
- MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
-
if (IsPersonality)
getStreamer().emitCFIPersonality(Sym, Encoding);
else
@@ -4920,13 +4910,10 @@ bool AsmParser::parseDirectiveComm(bool IsLocal) {
return true;
SMLoc IDLoc = getLexer().getLoc();
- StringRef Name;
- if (parseIdentifier(Name))
+ MCSymbol *Sym;
+ if (parseSymbol(Sym))
return TokError("expected identifier in directive");
- // Handle the identifier as the key symbol.
- MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
-
if (parseComma())
return true;
@@ -5756,10 +5743,9 @@ bool AsmParser::parseDirectiveAddrsig() {
}
bool AsmParser::parseDirectiveAddrsigSym() {
- StringRef Name;
- if (check(parseIdentifier(Name), "expected identifier") || parseEOL())
+ MCSymbol *Sym;
+ if (check(parseSymbol(Sym), "expected identifier") || parseEOL())
return true;
- MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
getStreamer().emitAddrsigSym(Sym);
return false;
}
diff --git a/llvm/lib/MC/MCParser/COFFAsmParser.cpp b/llvm/lib/MC/MCParser/COFFAsmParser.cpp
index 9fb17488a9e9c..5dd79946d8779 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;
diff --git a/llvm/lib/MC/MCParser/COFFMasmParser.cpp b/llvm/lib/MC/MCParser/COFFMasmParser.cpp
index 1bb617b327f1e..ef2815b037f2f 100644
--- a/llvm/lib/MC/MCParser/COFFMasmParser.cpp
+++ b/llvm/lib/MC/MCParser/COFFMasmParser.cpp
@@ -443,8 +443,8 @@ bool COFFMasmParser::parseDirectiveProc(StringRef Directive, SMLoc Loc) {
if (!getStreamer().getCurrentFragment())
return Error(getTok().getLoc(), "expected section directive");
- StringRef Label;
- if (getParser().parseIdentifier(Label))
+ MCSymbol *Sym;
+ if (getParser().parseSymbol(Sym))
return Error(Loc, "expected identifier for procedure");
if (getLexer().is(AsmToken::Identifier)) {
StringRef nextVal = getTok().getString();
@@ -459,12 +459,12 @@ bool COFFMasmParser::parseDirectiveProc(StringRef Directive, SMLoc Loc) {
nextLoc = getTok().getLoc();
}
}
- auto *Sym =
- static_cast<MCSymbolCOFF *>(getContext().getOrCreateSymbol(Label));
// Define symbol as simple external function
- Sym->setExternal(true);
- Sym->setType(COFF::IMAGE_SYM_DTYPE_FUNCTION << COFF::SCT_COMPLEX_TYPE_SHIFT);
+ auto *COFFSym = static_cast<MCSymbolCOFF *>(Sym);
+ COFFSym->setExternal(true);
+ COFFSym->setType(COFF::IMAGE_SYM_DTYPE_FUNCTION
+ << COFF::SCT_COMPLEX_TYPE_SHIFT);
bool Framed = false;
if (getLexer().is(AsmToken::Identifier) &&
@@ -475,7 +475,7 @@ bool COFFMasmParser::parseDirectiveProc(StringRef Directive, SMLoc Loc) {
}
getStreamer().emitLabel(Sym, Loc);
- CurrentProcedures.push_back(Label);
+ CurrentProcedures.push_back(Sym->getName());
CurrentProceduresFramed.push_back(Framed);
return false;
}
diff --git a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp
index a9095b3298f5e..189f8070de8bc 100644
--- a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp
@@ -501,13 +501,10 @@ bool DarwinAsmParser::parseSectionSwitch(StringRef Segment, StringRef Section,
/// parseDirectiveAltEntry
/// ::= .alt_entry identifier
bool DarwinAsmParser::parseDirectiveAltEntry(StringRef, SMLoc) {
- StringRef Name;
- if (getParser().parseIdentifier(Name))
+ MCSymbol *Sym;
+ if (getParser().parseSymbol(Sym))
return TokError("expected identifier in directive");
- // Look up symbol.
- MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
-
if (Sym->isDefined())
return TokError(".alt_entry must preceed symbol definition");
@@ -521,13 +518,10 @@ bool DarwinAsmParser::parseDirectiveAltEntry(StringRef, SMLoc) {
/// parseDirectiveDesc
/// ::= .desc identifier , expression
bool DarwinAsmParser::parseDirectiveDesc(StringRef, SMLoc) {
- StringRef Name;
- if (getParser().parseIdentifier(Name))
+ MCSymbol *Sym;
+ if (getParser().parseSymbol(Sym))
return TokError("expected identifier in directive");
- // Handle the identifier as the key symbol.
- MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
-
if (getLexer().isNot(AsmToken::Comma))
return TokError("unexpected token in '.desc' directive");
Lex();
@@ -560,18 +554,16 @@ bool DarwinAsmParser::parseDirectiveIndirectSymbol(StringRef, SMLoc Loc) {
return Error(Loc, "indirect symbol not in a symbol pointer or stub "
"section");
- StringRef Name;
- if (getParser().parseIdentifier(Name))
+ MCSymbol *Sym;
+ if (getParser().parseSymbol(Sym))
return TokError("expected identifier in .indirect_symbol directive");
- MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
-
// Assembler local symbols don't make any sense here. Complain loudly.
if (Sym->isTemporary())
return TokError("non-local symbol required in directive");
if (!getStreamer().emitSymbolAttribute(Sym, MCSA_IndirectSymbol))
- return TokError("unable to emit indirect symbol attribute for: " + Name);
+ return TokError("unable to emit indirect symbol attribute for: " + Sym->getName());
if (getLexer().isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in '.indirect_symbol' directive");
@@ -633,13 +625,10 @@ bool DarwinAsmParser::parseDirectiveLinkerOption(StringRef IDVal, SMLoc) {
/// parseDirectiveLsym
/// ::= .lsym identifier , expression
bool DarwinAsmParser::parseDirectiveLsym(StringRef, SMLoc) {
- StringRef Name;
- if (getParser().parseIdentifier(Name))
+ MCSymbol *Sym;
+ if (getParser().parseSymbol(Sym))
return TokError("expected identifier in directive");
- // Handle the identifier as the key symbol.
- MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
-
if (getLexer().isNot(AsmToken::Comma))
return TokError("unexpected token in '.lsym' directive");
Lex();
@@ -826,13 +815,10 @@ bool DarwinAsmParser::parseDirectiveSubsectionsViaSymbols(StringRef, SMLoc) {
/// ::= .tbss identifier, size, align
bool DarwinAsmParser::parseDirectiveTBSS(StringRef, SMLoc) {
SMLoc IDLoc = getLexer().getLoc();
- StringRef Name;
- if (getParser().parseIdentifier(Name))
+ MCSymbol *Sym;
+ if (getParser().parseSymbol(Sym))
return TokError("expected identifier in directive");
- // Handle the identifier as the key symbol.
- MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
-
if (getLexer().isNot(AsmToken::Comma))
return TokError("unexpected token in directive");
Lex();
@@ -911,13 +897,10 @@ bool DarwinAsmParser::parseDirectiveZerofill(StringRef, SMLoc) {
Lex();
SMLoc IDLoc = getLexer().getLoc();
- StringRef IDStr;
- if (getParser().parseIdentifier(IDStr))
+ MCSymbol *Sym;
+ if (getParser().parseSymbol(Sym))
return TokError("expected identifier in directive");
- // handle the identifier as the key symbol.
- MCSymbol *Sym = getContext().getOrCreateSymbol(IDStr);
-
if (getLexer().isNot(AsmToken::Comma))
return TokError("unexpected token in directive");
Lex();
diff --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
index 513f3b3da7813..19da9f57a4a6f 100644
--- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
@@ -196,10 +196,9 @@ bool ELFAsmParser::parseSectionSwitch(StringRef Section, unsigned Type,
}
bool ELFAsmParser::parseDirectiveSize(StringRef, SMLoc) {
- StringRef Name;
- if (getParser().parseIdentifier(Name))
+ MCSymbol *Sym;
+ if (getParser().parseSymbol(Sym))
return TokError("expected identifier");
- auto *Sym = static_cast<MCSymbolELF *>(getContext().getOrCreateSymbol(Name));
if (getLexer().isNot(AsmToken::Comma))
return TokError("expected comma");
@@ -712,13 +711,10 @@ static MCSymbolAttr MCAttrForString(StringRef Type) {
/// ::= .type identifier , %attribute
/// ::= .type identifier , "attribute"
bool ELFAsmParser::parseDirectiveType(StringRef, SMLoc) {
- StringRef Name;
- if (getParser().parseIdentifier(Name))
+ MCSymbol *Sym;
+ if (getParser().parseSymbol(Sym))
return TokError("expected identifier");
- // Handle the identifier as the key symbol.
- MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
-
bool AllowAt = getLexer().getAllowAtInIdentifier();
if (!AllowAt &&
!getContext().getAsmInfo()->getCommentString().starts_with("@"))
@@ -790,8 +786,9 @@ bool ELFAsmParser::parseDirectiveIdent(StringRef, SMLoc) {
/// parseDirectiveSymver
/// ::= .symver foo, bar2@zed
bool ELFAsmParser::parseDirectiveSymver(StringRef, SMLoc) {
- StringRef OriginalName, Name, Action;
- if (getParser().parseIdentifier(OriginalName))
+ MCSymbol *OriginalSym;
+ StringRef Name, Action;
+ if (getParser().parseSymbol(OriginalSym))
return TokError("expected identifier");
if (getLexer().isNot(AsmToken::Comma))
@@ -819,8 +816,7 @@ bool ELFAsmParser::pars...
[truncated]
|
|
@llvm/pr-subscribers-backend-webassembly Author: Nikita Popov (nikic) ChangesThis combines parseIdentifier() + getOrCreateSymbol(). This should make it a bit easier if we want to change the parseIdentifier() API. Patch is 25.47 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/158106.diff 9 Files Affected:
diff --git a/llvm/include/llvm/MC/MCParser/MCAsmParser.h b/llvm/include/llvm/MC/MCParser/MCAsmParser.h
index cb9bd5c600d52..e3f44a08db641 100644
--- a/llvm/include/llvm/MC/MCParser/MCAsmParser.h
+++ b/llvm/include/llvm/MC/MCParser/MCAsmParser.h
@@ -279,6 +279,9 @@ class LLVM_ABI MCAsmParser {
/// Res to the identifier contents.
virtual bool parseIdentifier(StringRef &Res) = 0;
+ /// Parse identifier and get or create symbol for it.
+ bool parseSymbol(MCSymbol *&Res);
+
/// Parse up to the end of statement and return the contents from the
/// current token until the end of the statement; the current token on exit
/// will be either the EndOfStatement or EOF.
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp
index fb183a10b3d37..cec2afea9a70b 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -3876,20 +3876,17 @@ bool AsmParser::parseDirectiveCVLoc() {
/// ::= .cv_linetable FunctionId, FnStart, FnEnd
bool AsmParser::parseDirectiveCVLinetable() {
int64_t FunctionId;
- StringRef FnStartName, FnEndName;
+ MCSymbol *FnStartSym, *FnEndSym;
SMLoc Loc = getTok().getLoc();
if (parseCVFunctionId(FunctionId, ".cv_linetable") || parseComma() ||
parseTokenLoc(Loc) ||
- check(parseIdentifier(FnStartName), Loc,
+ check(parseSymbol(FnStartSym), Loc,
"expected identifier in directive") ||
parseComma() || parseTokenLoc(Loc) ||
- check(parseIdentifier(FnEndName), Loc,
+ check(parseSymbol(FnEndSym), Loc,
"expected identifier in directive"))
return true;
- MCSymbol *FnStartSym = getContext().getOrCreateSymbol(FnStartName);
- MCSymbol *FnEndSym = getContext().getOrCreateSymbol(FnEndName);
-
getStreamer().emitCVLinetableDirective(FunctionId, FnStartSym, FnEndSym);
return false;
}
@@ -3898,7 +3895,7 @@ bool AsmParser::parseDirectiveCVLinetable() {
/// ::= .cv_inline_linetable PrimaryFunctionId FileId LineNum FnStart FnEnd
bool AsmParser::parseDirectiveCVInlineLinetable() {
int64_t PrimaryFunctionId, SourceFileId, SourceLineNum;
- StringRef FnStartName, FnEndName;
+ MCSymbol *FnStartSym, *FnEndSym;
SMLoc Loc = getTok().getLoc();
if (parseCVFunctionId(PrimaryFunctionId, ".cv_inline_linetable") ||
parseTokenLoc(Loc) ||
@@ -3908,16 +3905,14 @@ bool AsmParser::parseDirectiveCVInlineLinetable() {
parseIntToken(SourceLineNum, "expected SourceLineNum") ||
check(SourceLineNum < 0, Loc, "Line number less than zero") ||
parseTokenLoc(Loc) ||
- check(parseIdentifier(FnStartName), Loc, "expected identifier") ||
+ check(parseSymbol(FnStartSym), Loc, "expected identifier") ||
parseTokenLoc(Loc) ||
- check(parseIdentifier(FnEndName), Loc, "expected identifier"))
+ check(parseSymbol(FnEndSym), Loc, "expected identifier"))
return true;
if (parseEOL())
return true;
- MCSymbol *FnStartSym = getContext().getOrCreateSymbol(FnStartName);
- MCSymbol *FnEndSym = getContext().getOrCreateSymbol(FnEndName);
getStreamer().emitCVInlineLinetableDirective(PrimaryFunctionId, SourceFileId,
SourceLineNum, FnStartSym,
FnEndSym);
@@ -3938,16 +3933,14 @@ bool AsmParser::parseDirectiveCVDefRange() {
std::vector<std::pair<const MCSymbol *, const MCSymbol *>> Ranges;
while (getLexer().is(AsmToken::Identifier)) {
Loc = getLexer().getLoc();
- StringRef GapStartName;
- if (parseIdentifier(GapStartName))
+ MCSymbol *GapStartSym;
+ if (parseSymbol(GapStartSym))
return Error(Loc, "expected identifier in directive");
- MCSymbol *GapStartSym = getContext().getOrCreateSymbol(GapStartName);
Loc = getLexer().getLoc();
- StringRef GapEndName;
- if (parseIdentifier(GapEndName))
+ MCSymbol *GapEndSym;
+ if (parseSymbol(GapEndSym))
return Error(Loc, "expected identifier in directive");
- MCSymbol *GapEndSym = getContext().getOrCreateSymbol(GapEndName);
Ranges.push_back({GapStartSym, GapEndSym});
}
@@ -4084,12 +4077,11 @@ bool AsmParser::parseDirectiveCVFileChecksumOffset() {
/// ::= .cv_fpo_data procsym
bool AsmParser::parseDirectiveCVFPOData() {
SMLoc DirLoc = getLexer().getLoc();
- StringRef ProcName;
- if (parseIdentifier(ProcName))
+ MCSymbol *ProcSym;
+ if (parseSymbol(ProcSym))
return TokError("expected symbol name");
if (parseEOL())
return true;
- MCSymbol *ProcSym = getContext().getOrCreateSymbol(ProcName);
getStreamer().emitCVFPOData(ProcSym, DirLoc);
return false;
}
@@ -4311,15 +4303,13 @@ bool AsmParser::parseDirectiveCFIPersonalityOrLsda(bool IsPersonality) {
if (Encoding == dwarf::DW_EH_PE_omit)
return false;
- StringRef Name;
+ MCSymbol *Sym;
if (check(!isValidEncoding(Encoding), "unsupported encoding.") ||
parseComma() ||
- check(parseIdentifier(Name), "expected identifier in directive") ||
+ check(parseSymbol(Sym), "expected identifier in directive") ||
parseEOL())
return true;
- MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
-
if (IsPersonality)
getStreamer().emitCFIPersonality(Sym, Encoding);
else
@@ -4920,13 +4910,10 @@ bool AsmParser::parseDirectiveComm(bool IsLocal) {
return true;
SMLoc IDLoc = getLexer().getLoc();
- StringRef Name;
- if (parseIdentifier(Name))
+ MCSymbol *Sym;
+ if (parseSymbol(Sym))
return TokError("expected identifier in directive");
- // Handle the identifier as the key symbol.
- MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
-
if (parseComma())
return true;
@@ -5756,10 +5743,9 @@ bool AsmParser::parseDirectiveAddrsig() {
}
bool AsmParser::parseDirectiveAddrsigSym() {
- StringRef Name;
- if (check(parseIdentifier(Name), "expected identifier") || parseEOL())
+ MCSymbol *Sym;
+ if (check(parseSymbol(Sym), "expected identifier") || parseEOL())
return true;
- MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
getStreamer().emitAddrsigSym(Sym);
return false;
}
diff --git a/llvm/lib/MC/MCParser/COFFAsmParser.cpp b/llvm/lib/MC/MCParser/COFFAsmParser.cpp
index 9fb17488a9e9c..5dd79946d8779 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;
diff --git a/llvm/lib/MC/MCParser/COFFMasmParser.cpp b/llvm/lib/MC/MCParser/COFFMasmParser.cpp
index 1bb617b327f1e..ef2815b037f2f 100644
--- a/llvm/lib/MC/MCParser/COFFMasmParser.cpp
+++ b/llvm/lib/MC/MCParser/COFFMasmParser.cpp
@@ -443,8 +443,8 @@ bool COFFMasmParser::parseDirectiveProc(StringRef Directive, SMLoc Loc) {
if (!getStreamer().getCurrentFragment())
return Error(getTok().getLoc(), "expected section directive");
- StringRef Label;
- if (getParser().parseIdentifier(Label))
+ MCSymbol *Sym;
+ if (getParser().parseSymbol(Sym))
return Error(Loc, "expected identifier for procedure");
if (getLexer().is(AsmToken::Identifier)) {
StringRef nextVal = getTok().getString();
@@ -459,12 +459,12 @@ bool COFFMasmParser::parseDirectiveProc(StringRef Directive, SMLoc Loc) {
nextLoc = getTok().getLoc();
}
}
- auto *Sym =
- static_cast<MCSymbolCOFF *>(getContext().getOrCreateSymbol(Label));
// Define symbol as simple external function
- Sym->setExternal(true);
- Sym->setType(COFF::IMAGE_SYM_DTYPE_FUNCTION << COFF::SCT_COMPLEX_TYPE_SHIFT);
+ auto *COFFSym = static_cast<MCSymbolCOFF *>(Sym);
+ COFFSym->setExternal(true);
+ COFFSym->setType(COFF::IMAGE_SYM_DTYPE_FUNCTION
+ << COFF::SCT_COMPLEX_TYPE_SHIFT);
bool Framed = false;
if (getLexer().is(AsmToken::Identifier) &&
@@ -475,7 +475,7 @@ bool COFFMasmParser::parseDirectiveProc(StringRef Directive, SMLoc Loc) {
}
getStreamer().emitLabel(Sym, Loc);
- CurrentProcedures.push_back(Label);
+ CurrentProcedures.push_back(Sym->getName());
CurrentProceduresFramed.push_back(Framed);
return false;
}
diff --git a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp
index a9095b3298f5e..189f8070de8bc 100644
--- a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp
@@ -501,13 +501,10 @@ bool DarwinAsmParser::parseSectionSwitch(StringRef Segment, StringRef Section,
/// parseDirectiveAltEntry
/// ::= .alt_entry identifier
bool DarwinAsmParser::parseDirectiveAltEntry(StringRef, SMLoc) {
- StringRef Name;
- if (getParser().parseIdentifier(Name))
+ MCSymbol *Sym;
+ if (getParser().parseSymbol(Sym))
return TokError("expected identifier in directive");
- // Look up symbol.
- MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
-
if (Sym->isDefined())
return TokError(".alt_entry must preceed symbol definition");
@@ -521,13 +518,10 @@ bool DarwinAsmParser::parseDirectiveAltEntry(StringRef, SMLoc) {
/// parseDirectiveDesc
/// ::= .desc identifier , expression
bool DarwinAsmParser::parseDirectiveDesc(StringRef, SMLoc) {
- StringRef Name;
- if (getParser().parseIdentifier(Name))
+ MCSymbol *Sym;
+ if (getParser().parseSymbol(Sym))
return TokError("expected identifier in directive");
- // Handle the identifier as the key symbol.
- MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
-
if (getLexer().isNot(AsmToken::Comma))
return TokError("unexpected token in '.desc' directive");
Lex();
@@ -560,18 +554,16 @@ bool DarwinAsmParser::parseDirectiveIndirectSymbol(StringRef, SMLoc Loc) {
return Error(Loc, "indirect symbol not in a symbol pointer or stub "
"section");
- StringRef Name;
- if (getParser().parseIdentifier(Name))
+ MCSymbol *Sym;
+ if (getParser().parseSymbol(Sym))
return TokError("expected identifier in .indirect_symbol directive");
- MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
-
// Assembler local symbols don't make any sense here. Complain loudly.
if (Sym->isTemporary())
return TokError("non-local symbol required in directive");
if (!getStreamer().emitSymbolAttribute(Sym, MCSA_IndirectSymbol))
- return TokError("unable to emit indirect symbol attribute for: " + Name);
+ return TokError("unable to emit indirect symbol attribute for: " + Sym->getName());
if (getLexer().isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in '.indirect_symbol' directive");
@@ -633,13 +625,10 @@ bool DarwinAsmParser::parseDirectiveLinkerOption(StringRef IDVal, SMLoc) {
/// parseDirectiveLsym
/// ::= .lsym identifier , expression
bool DarwinAsmParser::parseDirectiveLsym(StringRef, SMLoc) {
- StringRef Name;
- if (getParser().parseIdentifier(Name))
+ MCSymbol *Sym;
+ if (getParser().parseSymbol(Sym))
return TokError("expected identifier in directive");
- // Handle the identifier as the key symbol.
- MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
-
if (getLexer().isNot(AsmToken::Comma))
return TokError("unexpected token in '.lsym' directive");
Lex();
@@ -826,13 +815,10 @@ bool DarwinAsmParser::parseDirectiveSubsectionsViaSymbols(StringRef, SMLoc) {
/// ::= .tbss identifier, size, align
bool DarwinAsmParser::parseDirectiveTBSS(StringRef, SMLoc) {
SMLoc IDLoc = getLexer().getLoc();
- StringRef Name;
- if (getParser().parseIdentifier(Name))
+ MCSymbol *Sym;
+ if (getParser().parseSymbol(Sym))
return TokError("expected identifier in directive");
- // Handle the identifier as the key symbol.
- MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
-
if (getLexer().isNot(AsmToken::Comma))
return TokError("unexpected token in directive");
Lex();
@@ -911,13 +897,10 @@ bool DarwinAsmParser::parseDirectiveZerofill(StringRef, SMLoc) {
Lex();
SMLoc IDLoc = getLexer().getLoc();
- StringRef IDStr;
- if (getParser().parseIdentifier(IDStr))
+ MCSymbol *Sym;
+ if (getParser().parseSymbol(Sym))
return TokError("expected identifier in directive");
- // handle the identifier as the key symbol.
- MCSymbol *Sym = getContext().getOrCreateSymbol(IDStr);
-
if (getLexer().isNot(AsmToken::Comma))
return TokError("unexpected token in directive");
Lex();
diff --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
index 513f3b3da7813..19da9f57a4a6f 100644
--- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
@@ -196,10 +196,9 @@ bool ELFAsmParser::parseSectionSwitch(StringRef Section, unsigned Type,
}
bool ELFAsmParser::parseDirectiveSize(StringRef, SMLoc) {
- StringRef Name;
- if (getParser().parseIdentifier(Name))
+ MCSymbol *Sym;
+ if (getParser().parseSymbol(Sym))
return TokError("expected identifier");
- auto *Sym = static_cast<MCSymbolELF *>(getContext().getOrCreateSymbol(Name));
if (getLexer().isNot(AsmToken::Comma))
return TokError("expected comma");
@@ -712,13 +711,10 @@ static MCSymbolAttr MCAttrForString(StringRef Type) {
/// ::= .type identifier , %attribute
/// ::= .type identifier , "attribute"
bool ELFAsmParser::parseDirectiveType(StringRef, SMLoc) {
- StringRef Name;
- if (getParser().parseIdentifier(Name))
+ MCSymbol *Sym;
+ if (getParser().parseSymbol(Sym))
return TokError("expected identifier");
- // Handle the identifier as the key symbol.
- MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
-
bool AllowAt = getLexer().getAllowAtInIdentifier();
if (!AllowAt &&
!getContext().getAsmInfo()->getCommentString().starts_with("@"))
@@ -790,8 +786,9 @@ bool ELFAsmParser::parseDirectiveIdent(StringRef, SMLoc) {
/// parseDirectiveSymver
/// ::= .symver foo, bar2@zed
bool ELFAsmParser::parseDirectiveSymver(StringRef, SMLoc) {
- StringRef OriginalName, Name, Action;
- if (getParser().parseIdentifier(OriginalName))
+ MCSymbol *OriginalSym;
+ StringRef Name, Action;
+ if (getParser().parseSymbol(OriginalSym))
return TokError("expected identifier");
if (getLexer().isNot(AsmToken::Comma))
@@ -819,8 +816,7 @@ bool ELFAsmParser::pars...
[truncated]
|
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for migrating all the call sites:)
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/154/builds/21404 Here is the relevant piece of the build log for the reference |
The MCContext::getOrCreateSymbol change in llvm#138817 was a workaround. With llvm#158106, we can replace `getOrCreateSymbol` with `parseSymbol`, in llvm/lib/MC/MCParser to handle backslash-escaped symbols.
This combines parseIdentifier() + getOrCreateSymbol(). This should make it a bit easier if we want to change the parseIdentifier() API. (cherry picked from commit 76aba5d)
The MCContext::getOrCreateSymbol change in llvm#138817 was a workaround. With llvm#158106, we can replace `getOrCreateSymbol` with `parseSymbol`, in llvm/lib/MC/MCParser to handle backslash-escaped symbols. (cherry picked from commit 0cf6688)
This combines parseIdentifier() + getOrCreateSymbol(). This should make it a bit easier if we want to change the parseIdentifier() API. (cherry picked from commit 76aba5d)
The MCContext::getOrCreateSymbol change in llvm#138817 was a workaround. With llvm#158106, we can replace `getOrCreateSymbol` with `parseSymbol`, in llvm/lib/MC/MCParser to handle backslash-escaped symbols. (cherry picked from commit 0cf6688)
This combines parseIdentifier() + getOrCreateSymbol(). This should make it a bit easier if we want to change the parseIdentifier() API. (cherry picked from commit 76aba5d)
The MCContext::getOrCreateSymbol change in llvm#138817 was a workaround. With llvm#158106, we can replace `getOrCreateSymbol` with `parseSymbol`, in llvm/lib/MC/MCParser to handle backslash-escaped symbols. (cherry picked from commit 0cf6688)
This reverts commit 05746a1.
This combines parseIdentifier() + getOrCreateSymbol(). This should make it a bit easier if we want to change the parseIdentifier() API.