forked from OSchip/llvm-project
Move more code to helper functions. NFC.
llvm-svn: 293715
This commit is contained in:
parent
23ccc29197
commit
a86be22230
|
@ -143,6 +143,9 @@ private:
|
|||
bool ParseSectionArguments(bool IsPush, SMLoc loc);
|
||||
unsigned parseSunStyleSectionFlags();
|
||||
bool maybeParseSectionType(StringRef &TypeName);
|
||||
bool parseMergeSize(int64_t &Size);
|
||||
bool parseGroup(StringRef &GroupName);
|
||||
bool maybeParseUniqueID(int64_t &UniqueID);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -382,6 +385,57 @@ bool ELFAsmParser::maybeParseSectionType(StringRef &TypeName) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool ELFAsmParser::parseMergeSize(int64_t &Size) {
|
||||
if (getLexer().isNot(AsmToken::Comma))
|
||||
return TokError("expected the entry size");
|
||||
Lex();
|
||||
if (getParser().parseAbsoluteExpression(Size))
|
||||
return true;
|
||||
if (Size <= 0)
|
||||
return TokError("entry size must be positive");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ELFAsmParser::parseGroup(StringRef &GroupName) {
|
||||
MCAsmLexer &L = getLexer();
|
||||
if (L.isNot(AsmToken::Comma))
|
||||
return TokError("expected group name");
|
||||
Lex();
|
||||
if (getParser().parseIdentifier(GroupName))
|
||||
return true;
|
||||
if (L.is(AsmToken::Comma)) {
|
||||
Lex();
|
||||
StringRef Linkage;
|
||||
if (getParser().parseIdentifier(Linkage))
|
||||
return true;
|
||||
if (Linkage != "comdat")
|
||||
return TokError("Linkage must be 'comdat'");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ELFAsmParser::maybeParseUniqueID(int64_t &UniqueID) {
|
||||
MCAsmLexer &L = getLexer();
|
||||
if (L.isNot(AsmToken::Comma))
|
||||
return false;
|
||||
Lex();
|
||||
StringRef UniqueStr;
|
||||
if (getParser().parseIdentifier(UniqueStr))
|
||||
return TokError("expected identifier in directive");
|
||||
if (UniqueStr != "unique")
|
||||
return TokError("expected 'unique'");
|
||||
if (L.isNot(AsmToken::Comma))
|
||||
return TokError("expected commma");
|
||||
Lex();
|
||||
if (getParser().parseAbsoluteExpression(UniqueID))
|
||||
return true;
|
||||
if (UniqueID < 0)
|
||||
return TokError("unique id must be positive");
|
||||
if (!isUInt<32>(UniqueID) || UniqueID == ~0U)
|
||||
return TokError("unique id is too large");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ELFAsmParser::ParseSectionArguments(bool IsPush, SMLoc loc) {
|
||||
StringRef SectionName;
|
||||
|
||||
|
@ -451,47 +505,14 @@ bool ELFAsmParser::ParseSectionArguments(bool IsPush, SMLoc loc) {
|
|||
return TokError("unexpected token in directive");
|
||||
}
|
||||
|
||||
if (Mergeable) {
|
||||
if (getLexer().isNot(AsmToken::Comma))
|
||||
return TokError("expected the entry size");
|
||||
Lex();
|
||||
if (getParser().parseAbsoluteExpression(Size))
|
||||
if (Mergeable)
|
||||
if (parseMergeSize(Size))
|
||||
return true;
|
||||
if (Size <= 0)
|
||||
return TokError("entry size must be positive");
|
||||
}
|
||||
|
||||
if (Group) {
|
||||
if (getLexer().isNot(AsmToken::Comma))
|
||||
return TokError("expected group name");
|
||||
Lex();
|
||||
if (getParser().parseIdentifier(GroupName))
|
||||
if (Group)
|
||||
if (parseGroup(GroupName))
|
||||
return true;
|
||||
if (getLexer().is(AsmToken::Comma)) {
|
||||
Lex();
|
||||
StringRef Linkage;
|
||||
if (getParser().parseIdentifier(Linkage))
|
||||
return true;
|
||||
if (Linkage != "comdat")
|
||||
return TokError("Linkage must be 'comdat'");
|
||||
}
|
||||
}
|
||||
if (getLexer().is(AsmToken::Comma)) {
|
||||
Lex();
|
||||
if (getParser().parseIdentifier(UniqueStr))
|
||||
return TokError("expected identifier in directive");
|
||||
if (UniqueStr != "unique")
|
||||
return TokError("expected 'unique'");
|
||||
if (getLexer().isNot(AsmToken::Comma))
|
||||
return TokError("expected commma");
|
||||
Lex();
|
||||
if (getParser().parseAbsoluteExpression(UniqueID))
|
||||
return true;
|
||||
if (UniqueID < 0)
|
||||
return TokError("unique id must be positive");
|
||||
if (!isUInt<32>(UniqueID) || UniqueID == ~0U)
|
||||
return TokError("unique id is too large");
|
||||
}
|
||||
if (maybeParseUniqueID(UniqueID))
|
||||
return true;
|
||||
}
|
||||
|
||||
EndStmt:
|
||||
|
|
Loading…
Reference in New Issue