Fix massive resource leaks in the bytecode reader. Reading a bytecode file
with ParseBytecodeFile used to leak both a ModuleProvider (and related
bytecode parser stuff attached to it) AND a file descriptor, which was
never closed. This prevented gccld/llvm-ld/llvm-link from linking together
apps with more that ~252 .bc files on darwin.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30912 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Bytecode/Reader/Reader.h b/lib/Bytecode/Reader/Reader.h
index fcf79b4..86ccc20 100644
--- a/lib/Bytecode/Reader/Reader.h
+++ b/lib/Bytecode/Reader/Reader.h
@@ -248,6 +248,12 @@
/// @brief Parse a string constants block
void ParseStringConstants(unsigned NumEntries, ValueTable &Tab);
+ /// @brief Release our memory.
+ void freeState() {
+ freeTable(FunctionValues);
+ freeTable(ModuleValues);
+ }
+
/// @}
/// @name Data
/// @{
@@ -467,12 +473,6 @@
/// given constant.
void ResolveReferencesToConstant(Constant *C, unsigned Typ, unsigned Slot);
- /// @brief Release our memory.
- void freeState() {
- freeTable(FunctionValues);
- freeTable(ModuleValues);
- }
-
/// @brief Free a table, making sure to free the ValueList in the table.
void freeTable(ValueTable &Tab) {
while (!Tab.empty()) {