mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-30 23:20:54 +00:00
LLParser: Split out ParseMetadataAttachment(), NFC
Make the code reusable for `Function` metadata attachments (PR23340). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235778 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2bf0f6fdab
commit
eb713786cd
@ -1490,6 +1490,18 @@ bool LLParser::ParseOptionalCallingConv(unsigned &CC) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/// ParseMetadataAttachment
|
||||
/// ::= !dbg !42
|
||||
bool LLParser::ParseMetadataAttachment(unsigned &Kind, MDNode *&MD) {
|
||||
assert(Lex.getKind() == lltok::MetadataVar && "Expected metadata attachment");
|
||||
|
||||
std::string Name = Lex.getStrVal();
|
||||
Kind = M->getMDKindID(Name);
|
||||
Lex.Lex();
|
||||
|
||||
return ParseMDNode(MD);
|
||||
}
|
||||
|
||||
/// ParseInstructionMetadata
|
||||
/// ::= !dbg !42 (',' !dbg !57)*
|
||||
bool LLParser::ParseInstructionMetadata(Instruction *Inst,
|
||||
@ -1498,12 +1510,9 @@ bool LLParser::ParseInstructionMetadata(Instruction *Inst,
|
||||
if (Lex.getKind() != lltok::MetadataVar)
|
||||
return TokError("expected metadata after comma");
|
||||
|
||||
std::string Name = Lex.getStrVal();
|
||||
unsigned MDK = M->getMDKindID(Name);
|
||||
Lex.Lex();
|
||||
|
||||
unsigned MDK;
|
||||
MDNode *N;
|
||||
if (ParseMDNode(N))
|
||||
if (ParseMetadataAttachment(MDK, N))
|
||||
return true;
|
||||
|
||||
Inst->setMetadata(MDK, N);
|
||||
|
@ -392,6 +392,7 @@ namespace llvm {
|
||||
bool ParseMDNode(MDNode *&MD);
|
||||
bool ParseMDNodeTail(MDNode *&MD);
|
||||
bool ParseMDNodeVector(SmallVectorImpl<Metadata *> &MDs);
|
||||
bool ParseMetadataAttachment(unsigned &Kind, MDNode *&MD);
|
||||
bool ParseInstructionMetadata(Instruction *Inst, PerFunctionState *PFS);
|
||||
|
||||
template <class FieldTy>
|
||||
|
Loading…
Reference in New Issue
Block a user