Per code review:\

* Adjust indentation\
* Ensure memory do not leak if exceptions happen (std::auto_ptr use)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17885 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Reid Spencer
2004-11-16 06:47:41 +00:00
parent 87f90729d6
commit 99d3604acf

View File

@ -179,7 +179,10 @@ bool llvm::LinkInArchive(Module *M,
// Open the archive file // Open the archive file
if (Verbose) std::cerr << " Loading archive file '" << Filename << "'\n"; if (Verbose) std::cerr << " Loading archive file '" << Filename << "'\n";
Archive* arch = Archive::OpenAndLoadSymbols(sys::Path(Filename)); std::auto_ptr<Archive> AutoArch (
Archive::OpenAndLoadSymbols(sys::Path(Filename)));
Archive* arch = AutoArch.get();
// While we are linking in object files, loop. // While we are linking in object files, loop.
while (true) { while (true) {
@ -195,15 +198,14 @@ bool llvm::LinkInArchive(Module *M,
for (std::set<ModuleProvider*>::iterator I=Modules.begin(), E=Modules.end(); for (std::set<ModuleProvider*>::iterator I=Modules.begin(), E=Modules.end();
I != E; ++I) { I != E; ++I) {
// Get the module we must link in. // Get the module we must link in.
std::auto_ptr<Module> aModule((*I)->releaseModule()); std::auto_ptr<Module> AutoModule( (*I)->releaseModule() );
// Link it in. Module* aModule = AutoModule.get();
if (LinkModules(M, aModule.get(), ErrorMessage)) {
// don't create a memory leak // Link it in
delete arch; if (LinkModules(M, aModule, ErrorMessage))
return true; // Couldn't link in the right object file... return true; // Couldn't link in the right object file...
} }
}
// We have linked in a set of modules determined by the archive to satisfy // We have linked in a set of modules determined by the archive to satisfy
// our missing symbols. Linking in the new modules will have satisfied some // our missing symbols. Linking in the new modules will have satisfied some