<div dir="ltr">Even better!</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 7, 2016 at 8:59 PM, Mehdi Amini <span dir="ltr"><<a href="mailto:mehdi.amini@apple.com" target="_blank">mehdi.amini@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><br>
> On Jan 7, 2016, at 11:55 AM, Keno Fischer <<a href="mailto:kfischer@college.harvard.edu">kfischer@college.harvard.edu</a>> wrote:<br>
><br>
> loladiro added a comment.<br>
><br>
> Would the following be a better way to address this:<br>
><br>
>  diff --git a/lib/IR/AsmWriter.cpp b/lib/IR/AsmWriter.cpp<br>
>  index 185db47..949b710 100644<br>
>  --- a/lib/IR/AsmWriter.cpp<br>
>  +++ b/lib/IR/AsmWriter.cpp<br>
>  @@ -2052,7 +2052,8 @@ private:<br>
>     /// \brief Print out metadata attachments.<br>
>     void printMetadataAttachments(<br>
>         const SmallVectorImpl<std::pair<unsigned, MDNode *>> &MDs,<br>
>  -      StringRef Separator);<br>
>  +      StringRef Separator,<br>
>  +      LLVMContext &Context);<br>
><br>
>     // printInfoComment - Print a little comment after the instruction indicating<br>
>     // which slot it occupies.<br>
>  @@ -2627,7 +2628,7 @@ void AssemblyWriter::printFunction(const Function *F) {<br>
><br>
>     SmallVector<std::pair<unsigned, MDNode *>, 4> MDs;<br>
>     F->getAllMetadata(MDs);<br>
>  -  printMetadataAttachments(MDs, " ");<br>
>  +  printMetadataAttachments(MDs, " ", F->getContext());<br>
><br>
>     if (F->isDeclaration()) {<br>
>       Out << '\n';<br>
>  @@ -3111,7 +3112,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) {<br>
>     // Print Metadata info.<br>
>     SmallVector<std::pair<unsigned, MDNode *>, 4> InstMD;<br>
>     I.getAllMetadata(InstMD);<br>
>  -  printMetadataAttachments(InstMD, ", ");<br>
>  +  printMetadataAttachments(InstMD, ", ", I.getType()->getContext());<br>
><br>
>     // Print a nice comment.<br>
>     printInfoComment(I);<br>
>  @@ -3119,12 +3120,13 @@ void AssemblyWriter::printInstruction(const Instruction &I) {<br>
><br>
>   void AssemblyWriter::printMetadataAttachments(<br>
>       const SmallVectorImpl<std::pair<unsigned, MDNode *>> &MDs,<br>
>  -    StringRef Separator) {<br>
>  +    StringRef Separator,<br>
>  +    LLVMContext &Context) {<br>
>     if (MDs.empty())<br>
>       return;<br>
><br>
>     if (MDNames.empty())<br>
>  -    TheModule->getMDKindNames(MDNames);<br>
>  +    Context.getMDKindNames(MDNames);<br>
<br>
<br>
</div></div>Instead of adding a parameter, you should be able to get the context this way as well:<br>
<br>
MDs[0].second->getContext()<br>
<br>
—<br>
<span class="HOEnZb"><font color="#888888">Mehdi<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
<br>
<br>
><br>
>     for (const auto &I : MDs) {<br>
>       unsigned Kind = I.first;<br>
><br>
> That way you'd still get the names in the printout.<br>
><br>
><br>
> <a href="http://reviews.llvm.org/D15798" rel="noreferrer" target="_blank">http://reviews.llvm.org/D15798</a><br>
><br>
><br>
><br>
<br>
</div></div></blockquote></div><br></div>