diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-04-20 21:19:10 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-04-20 21:19:10 +0000 |
commit | d99dafe2e4a385dd2a6c76da6d8258deb100657b (patch) | |
tree | ba60bf957558bd114f25dbff3d4996b5d7a61c82 /tools/llvm-cat/llvm-cat.cpp | |
parent | 71d5a2540a98c81f5bcaeb48805e0e2881f530ef (diff) |
Notes
Diffstat (limited to 'tools/llvm-cat/llvm-cat.cpp')
-rw-r--r-- | tools/llvm-cat/llvm-cat.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/tools/llvm-cat/llvm-cat.cpp b/tools/llvm-cat/llvm-cat.cpp index 4d62099094bb..8a21a6d07caa 100644 --- a/tools/llvm-cat/llvm-cat.cpp +++ b/tools/llvm-cat/llvm-cat.cpp @@ -44,11 +44,16 @@ int main(int argc, char **argv) { std::unique_ptr<MemoryBuffer> MB = ExitOnErr( errorOrToExpected(MemoryBuffer::getFileOrSTDIN(InputFilename))); std::vector<BitcodeModule> Mods = ExitOnErr(getBitcodeModuleList(*MB)); - for (auto &BitcodeMod : Mods) + for (auto &BitcodeMod : Mods) { Buffer.insert(Buffer.end(), BitcodeMod.getBuffer().begin(), BitcodeMod.getBuffer().end()); + Writer.copyStrtab(BitcodeMod.getStrtab()); + } } } else { + // The string table does not own strings added to it, some of which are + // owned by the modules; keep them alive until we write the string table. + std::vector<std::unique_ptr<Module>> OwnedMods; for (const auto &InputFilename : InputFilenames) { SMDiagnostic Err; std::unique_ptr<Module> M = parseIRFile(InputFilename, Err, Context); @@ -57,7 +62,9 @@ int main(int argc, char **argv) { return 1; } Writer.writeModule(M.get()); + OwnedMods.push_back(std::move(M)); } + Writer.writeStrtab(); } std::error_code EC; |