Deleted Added
full compact
BitcodeReader.cpp (194612) BitcodeReader.cpp (195340)
1//===- BitcodeReader.cpp - Internal BitcodeReader implementation ----------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 1073 unchanged lines hidden (view full) ---

1082 // Reject multiple MODULE_BLOCK's in a single bitstream.
1083 if (TheModule)
1084 return Error("Multiple MODULE_BLOCKs in same stream");
1085
1086 if (Stream.EnterSubBlock(bitc::MODULE_BLOCK_ID))
1087 return Error("Malformed block record");
1088
1089 // Otherwise, create the module.
1//===- BitcodeReader.cpp - Internal BitcodeReader implementation ----------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 1073 unchanged lines hidden (view full) ---

1082 // Reject multiple MODULE_BLOCK's in a single bitstream.
1083 if (TheModule)
1084 return Error("Multiple MODULE_BLOCKs in same stream");
1085
1086 if (Stream.EnterSubBlock(bitc::MODULE_BLOCK_ID))
1087 return Error("Malformed block record");
1088
1089 // Otherwise, create the module.
1090 TheModule = new Module(ModuleID);
1090 TheModule = new Module(ModuleID, Context);
1091
1092 SmallVector<uint64_t, 64> Record;
1093 std::vector<std::string> SectionTable;
1094 std::vector<std::string> GCTable;
1095
1096 // Read all the records for this module.
1097 while (!Stream.AtEndOfStream()) {
1098 unsigned Code = Stream.ReadCode();

--- 986 unchanged lines hidden (view full) ---

2085
2086//===----------------------------------------------------------------------===//
2087// External interface
2088//===----------------------------------------------------------------------===//
2089
2090/// getBitcodeModuleProvider - lazy function-at-a-time loading from a file.
2091///
2092ModuleProvider *llvm::getBitcodeModuleProvider(MemoryBuffer *Buffer,
1091
1092 SmallVector<uint64_t, 64> Record;
1093 std::vector<std::string> SectionTable;
1094 std::vector<std::string> GCTable;
1095
1096 // Read all the records for this module.
1097 while (!Stream.AtEndOfStream()) {
1098 unsigned Code = Stream.ReadCode();

--- 986 unchanged lines hidden (view full) ---

2085
2086//===----------------------------------------------------------------------===//
2087// External interface
2088//===----------------------------------------------------------------------===//
2089
2090/// getBitcodeModuleProvider - lazy function-at-a-time loading from a file.
2091///
2092ModuleProvider *llvm::getBitcodeModuleProvider(MemoryBuffer *Buffer,
2093 LLVMContext& Context,
2093 std::string *ErrMsg) {
2094 std::string *ErrMsg) {
2094 BitcodeReader *R = new BitcodeReader(Buffer);
2095 BitcodeReader *R = new BitcodeReader(Buffer, Context);
2095 if (R->ParseBitcode()) {
2096 if (ErrMsg)
2097 *ErrMsg = R->getErrorString();
2098
2099 // Don't let the BitcodeReader dtor delete 'Buffer'.
2100 R->releaseMemoryBuffer();
2101 delete R;
2102 return 0;
2103 }
2104 return R;
2105}
2106
2107/// ParseBitcodeFile - Read the specified bitcode file, returning the module.
2108/// If an error occurs, return null and fill in *ErrMsg if non-null.
2096 if (R->ParseBitcode()) {
2097 if (ErrMsg)
2098 *ErrMsg = R->getErrorString();
2099
2100 // Don't let the BitcodeReader dtor delete 'Buffer'.
2101 R->releaseMemoryBuffer();
2102 delete R;
2103 return 0;
2104 }
2105 return R;
2106}
2107
2108/// ParseBitcodeFile - Read the specified bitcode file, returning the module.
2109/// If an error occurs, return null and fill in *ErrMsg if non-null.
2109Module *llvm::ParseBitcodeFile(MemoryBuffer *Buffer, std::string *ErrMsg){
2110Module *llvm::ParseBitcodeFile(MemoryBuffer *Buffer, LLVMContext& Context,
2111 std::string *ErrMsg){
2110 BitcodeReader *R;
2112 BitcodeReader *R;
2111 R = static_cast<BitcodeReader*>(getBitcodeModuleProvider(Buffer, ErrMsg));
2113 R = static_cast<BitcodeReader*>(getBitcodeModuleProvider(Buffer, Context,
2114 ErrMsg));
2112 if (!R) return 0;
2113
2114 // Read in the entire module.
2115 Module *M = R->materializeModule(ErrMsg);
2116
2117 // Don't let the BitcodeReader dtor delete 'Buffer', regardless of whether
2118 // there was an error.
2119 R->releaseMemoryBuffer();
2120
2121 // If there was no error, tell ModuleProvider not to delete it when its dtor
2122 // is run.
2123 if (M)
2124 M = R->releaseModule(ErrMsg);
2125
2126 delete R;
2127 return M;
2128}
2115 if (!R) return 0;
2116
2117 // Read in the entire module.
2118 Module *M = R->materializeModule(ErrMsg);
2119
2120 // Don't let the BitcodeReader dtor delete 'Buffer', regardless of whether
2121 // there was an error.
2122 R->releaseMemoryBuffer();
2123
2124 // If there was no error, tell ModuleProvider not to delete it when its dtor
2125 // is run.
2126 if (M)
2127 M = R->releaseModule(ErrMsg);
2128
2129 delete R;
2130 return M;
2131}