<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jun 7, 2015 at 6:59 AM, Benjamin Kramer <span dir="ltr"><<a href="mailto:benny.kra@googlemail.com" target="_blank">benny.kra@googlemail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: d0k<br>
Date: Sun Jun 7 08:59:33 2015<br>
New Revision: 239251<br>
<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D239251-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=brEB4zfk_pvAvLEbvFxRqym4SUdJP4nX2a9fXRgbyCQ&s=jDotwLsIAxf7ttmeagah1f6As5KqDDcrrWEhpd8dJ24&e=" target="_blank">http://llvm.org/viewvc/llvm-project?rev=239251&view=rev</a><br>
Log:<br>
[AsmWriter] Rewrite module asm printing using StringRef::split.<br>
<br>
No change in output intended.<br>
<br>
Modified:<br>
llvm/trunk/lib/IR/AsmWriter.cpp<br>
<br>
Modified: llvm/trunk/lib/IR/AsmWriter.cpp<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_IR_AsmWriter.cpp-3Frev-3D239251-26r1-3D239250-26r2-3D239251-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=brEB4zfk_pvAvLEbvFxRqym4SUdJP4nX2a9fXRgbyCQ&s=FRxN8ptp_BjudbVwKPLnpe07dnY3zRhpaCb2zIDJWvY&e=" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AsmWriter.cpp?rev=239251&r1=239250&r2=239251&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/IR/AsmWriter.cpp (original)<br>
+++ llvm/trunk/lib/IR/AsmWriter.cpp Sun Jun 7 08:59:33 2015<br>
@@ -2140,27 +2140,20 @@ void AssemblyWriter::printModule(const M<br>
Out << "target triple = \"" << M->getTargetTriple() << "\"\n";<br>
<br>
if (!M->getModuleInlineAsm().empty()) {<br>
- // Split the string into lines, to make it easier to read the .ll file.<br>
- std::string Asm = M->getModuleInlineAsm();<br>
- size_t CurPos = 0;<br>
- size_t NewLine = Asm.find_first_of('\n', CurPos);<br>
Out << '\n';<br>
- while (NewLine != std::string::npos) {<br>
+<br>
+ // Split the string into lines, to make it easier to read the .ll file.<br>
+ StringRef Asm(M->getModuleInlineAsm());<br></blockquote><div><br>Prefer copy init over direct init (since direct init can invoke explicit conversions that might be more interesting/powerful - though I don't think there are any for StringRef?)?<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ do {<br>
+ StringRef Front;<br>
+ std::tie(Front, Asm) = Asm.split('\n');<br>
+<br>
// We found a newline, print the portion of the asm string from the<br>
// last newline up to this newline.<br>
Out << "module asm \"";<br>
- PrintEscapedString(std::string(Asm.begin()+CurPos, Asm.begin()+NewLine),<br>
- Out);<br>
- Out << "\"\n";<br>
- CurPos = NewLine+1;<br>
- NewLine = Asm.find_first_of('\n', CurPos);<br>
- }<br>
- std::string rest(Asm.begin()+CurPos, Asm.end());<br>
- if (!rest.empty()) {<br>
- Out << "module asm \"";<br>
- PrintEscapedString(rest, Out);<br>
+ PrintEscapedString(Front, Out);<br>
Out << "\"\n";<br>
- }<br>
+ } while (!Asm.empty());<br>
}<br>
<br>
printTypeIdentities();<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>