diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2015-06-07 13:59:33 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2015-06-07 13:59:33 +0000 |
commit | bbd05a2470a0cbdc1839e08ce88b27c792b67949 (patch) | |
tree | 75c97ea1ad6a996fe4d0270ccf4a75770b9a9ff0 /llvm | |
parent | a0cb17c3792c906985072064c884026f87ea74fd (diff) | |
download | bcm5719-llvm-bbd05a2470a0cbdc1839e08ce88b27c792b67949.tar.gz bcm5719-llvm-bbd05a2470a0cbdc1839e08ce88b27c792b67949.zip |
[AsmWriter] Rewrite module asm printing using StringRef::split.
No change in output intended.
llvm-svn: 239251
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/IR/AsmWriter.cpp | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp index 715aad8b03a..b147f9d79d6 100644 --- a/llvm/lib/IR/AsmWriter.cpp +++ b/llvm/lib/IR/AsmWriter.cpp @@ -2140,27 +2140,20 @@ void AssemblyWriter::printModule(const Module *M) { Out << "target triple = \"" << M->getTargetTriple() << "\"\n"; if (!M->getModuleInlineAsm().empty()) { - // Split the string into lines, to make it easier to read the .ll file. - std::string Asm = M->getModuleInlineAsm(); - size_t CurPos = 0; - size_t NewLine = Asm.find_first_of('\n', CurPos); Out << '\n'; - while (NewLine != std::string::npos) { + + // Split the string into lines, to make it easier to read the .ll file. + StringRef Asm(M->getModuleInlineAsm()); + do { + StringRef Front; + std::tie(Front, Asm) = Asm.split('\n'); + // We found a newline, print the portion of the asm string from the // last newline up to this newline. Out << "module asm \""; - PrintEscapedString(std::string(Asm.begin()+CurPos, Asm.begin()+NewLine), - Out); + PrintEscapedString(Front, Out); Out << "\"\n"; - CurPos = NewLine+1; - NewLine = Asm.find_first_of('\n', CurPos); - } - std::string rest(Asm.begin()+CurPos, Asm.end()); - if (!rest.empty()) { - Out << "module asm \""; - PrintEscapedString(rest, Out); - Out << "\"\n"; - } + } while (!Asm.empty()); } printTypeIdentities(); |