diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-06-18 20:07:35 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-06-18 20:07:35 +0000 |
commit | b2791542c2c5df2912848b8bdf06fb1093d4ac12 (patch) | |
tree | 6c94000869e97df4c747e7a7359ae6f74b3b93e8 /lib/Bitcode | |
parent | fff95d57a46e446b8224d1f8982e129fe3238070 (diff) | |
download | llvm-b2791542c2c5df2912848b8bdf06fb1093d4ac12.tar.gz llvm-b2791542c2c5df2912848b8bdf06fb1093d4ac12.tar.bz2 llvm-b2791542c2c5df2912848b8bdf06fb1093d4ac12.tar.xz |
Revert a C API difference that I incorrectly introduced.
LLVMGetBitcodeModuleInContext should not take ownership on error. I will
try to localize this odd api requirement, but this should get the bots green.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211213 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode')
-rw-r--r-- | lib/Bitcode/Reader/BitcodeReader.cpp | 1 | ||||
-rw-r--r-- | lib/Bitcode/Reader/BitcodeReader.h | 4 |
2 files changed, 5 insertions, 0 deletions
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 04fc18ec21..9c398277d4 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -3380,6 +3380,7 @@ ErrorOr<Module *> llvm::getLazyBitcodeModule(MemoryBuffer *Buffer, BitcodeReader *R = new BitcodeReader(Buffer, Context, BufferOwned); M->setMaterializer(R); if (std::error_code EC = R->ParseBitcodeInto(M)) { + R->releaseBuffer(); // Never take ownership on error. delete M; // Also deletes R. return EC; } diff --git a/lib/Bitcode/Reader/BitcodeReader.h b/lib/Bitcode/Reader/BitcodeReader.h index 51a8c6a111..6aa3e0e5ad 100644 --- a/lib/Bitcode/Reader/BitcodeReader.h +++ b/lib/Bitcode/Reader/BitcodeReader.h @@ -239,6 +239,10 @@ public: void FreeState(); + void releaseBuffer() { + Buffer = nullptr; + } + bool isMaterializable(const GlobalValue *GV) const override; bool isDematerializable(const GlobalValue *GV) const override; std::error_code Materialize(GlobalValue *GV) override; |