[llvm] r293715 - Move more code to helper functions. NFC.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 31 15:26:33 PST 2017
Author: rafael
Date: Tue Jan 31 17:26:32 2017
New Revision: 293715
URL: http://llvm.org/viewvc/llvm-project?rev=293715&view=rev
Log:
Move more code to helper functions. NFC.
Modified:
llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp
Modified: llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp?rev=293715&r1=293714&r2=293715&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp Tue Jan 31 17:26:32 2017
@@ -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
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
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))
- 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))
+ if (Group)
+ if (parseGroup(GroupName))
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:
More information about the llvm-commits
mailing list