AsmParser: PARSE_MD_FIELD() => ParseMDField(), NFC

Extract most of `PARSE_MD_FIELD()` into a function.

llvm-svn: 226539
This commit is contained in:
Duncan P. N. Exon Smith 2015-01-20 02:42:29 +00:00
parent 8839cb1dc8
commit a7477285b9
2 changed files with 13 additions and 13 deletions

View File

@ -2972,6 +2972,16 @@ bool LLParser::ParseMDFieldsImpl(ParserTy parseField, LocTy &ClosingLoc) {
return ParseToken(lltok::rparen, "expected ')' here");
}
template <class FieldTy>
bool LLParser::ParseMDField(StringRef Name, FieldTy &Result) {
if (Result.Seen)
return TokError("field '" + Name + "' cannot be specified more than once");
LocTy Loc = Lex.getLoc();
Lex.Lex();
return ParseMDField(Loc, Name, Result);
}
bool LLParser::ParseSpecializedMDNode(MDNode *&N, bool IsDistinct) {
assert(Lex.getKind() == lltok::MetadataVar && "Expected metadata type name");
#define DISPATCH_TO_PARSER(CLASS) \
@ -2990,19 +3000,8 @@ bool LLParser::ParseSpecializedMDNode(MDNode *&N, bool IsDistinct) {
if (!NAME.Seen) \
return Error(ClosingLoc, "missing required field '" #NAME "'");
#define PARSE_MD_FIELD(NAME, TYPE, DEFAULT) \
do { \
if (Lex.getStrVal() == #NAME) { \
if (NAME.Seen) \
return TokError("field '" #NAME \
"' cannot be specified more than once"); \
\
LocTy Loc = Lex.getLoc(); \
Lex.Lex(); \
if (ParseMDField(Loc, #NAME, NAME)) \
return true; \
return false; \
} \
} while (0)
if (Lex.getStrVal() == #NAME) \
return ParseMDField(#NAME, NAME);
#define PARSE_MD_FIELDS() \
VISIT_MD_FIELDS(DECLARE_FIELD, DECLARE_FIELD) \
do { \

View File

@ -421,6 +421,7 @@ namespace llvm {
bool ParseMDField(LocTy Loc, StringRef Name,
MDUnsignedField<uint32_t> &Result);
bool ParseMDField(LocTy Loc, StringRef Name, MDField &Result);
template <class FieldTy> bool ParseMDField(StringRef Name, FieldTy &Result);
template <class ParserTy>
bool ParseMDFieldsImplBody(ParserTy parseField);
template <class ParserTy>