summaryrefslogtreecommitdiff
path: root/tools/llvm-cat/llvm-cat.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/llvm-cat/llvm-cat.cpp')
-rw-r--r--tools/llvm-cat/llvm-cat.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/tools/llvm-cat/llvm-cat.cpp b/tools/llvm-cat/llvm-cat.cpp
index 4d62099094bb8..8a21a6d07caab 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;