[llvm] r235778 - LLParser: Split out ParseMetadataAttachment(), NFC
Duncan P. N. Exon Smith
dexonsmith at apple.com
Fri Apr 24 14:21:57 PDT 2015
Author: dexonsmith
Date: Fri Apr 24 16:21:57 2015
New Revision: 235778
URL: http://llvm.org/viewvc/llvm-project?rev=235778&view=rev
Log:
LLParser: Split out ParseMetadataAttachment(), NFC
Make the code reusable for `Function` metadata attachments (PR23340).
Modified:
llvm/trunk/lib/AsmParser/LLParser.cpp
llvm/trunk/lib/AsmParser/LLParser.h
Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=235778&r1=235777&r2=235778&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Fri Apr 24 16:21:57 2015
@@ -1490,6 +1490,18 @@ bool LLParser::ParseOptionalCallingConv(
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(
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);
Modified: llvm/trunk/lib/AsmParser/LLParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.h?rev=235778&r1=235777&r2=235778&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.h (original)
+++ llvm/trunk/lib/AsmParser/LLParser.h Fri Apr 24 16:21:57 2015
@@ -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>
More information about the llvm-commits
mailing list