diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2004-11-16 06:47:41 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2004-11-16 06:47:41 +0000 |
commit | 99d3604acf7eaa2ce11b29fc5a005047148cc9d9 (patch) | |
tree | aae8dce6cf99930618af10b88324826b6ce3fabf /lib | |
parent | 87f90729d699b23843e3f87b2565e9caac395e7b (diff) | |
download | external_llvm-99d3604acf7eaa2ce11b29fc5a005047148cc9d9.zip external_llvm-99d3604acf7eaa2ce11b29fc5a005047148cc9d9.tar.gz external_llvm-99d3604acf7eaa2ce11b29fc5a005047148cc9d9.tar.bz2 |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Linker/LinkArchives.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/lib/Linker/LinkArchives.cpp b/lib/Linker/LinkArchives.cpp index 2cccc98..1f4559c 100644 --- a/lib/Linker/LinkArchives.cpp +++ b/lib/Linker/LinkArchives.cpp @@ -163,9 +163,9 @@ static std::auto_ptr<Module> LoadObject(const std::string &FN, /// FALSE - No errors. /// bool llvm::LinkInArchive(Module *M, - const std::string &Filename, - std::string* ErrorMessage, - bool Verbose) + const std::string &Filename, + std::string* ErrorMessage, + bool Verbose) { // Find all of the symbols currently undefined in the bytecode program. // If all the symbols are defined, the program is complete, and there is @@ -179,13 +179,16 @@ bool llvm::LinkInArchive(Module *M, // Open the archive file 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 (true) { std::set<ModuleProvider*> Modules; // Find the modules we need to link - arch->findModulesDefiningSymbols(UndefinedSymbols,Modules); + arch->findModulesDefiningSymbols(UndefinedSymbols, Modules); // If we didn't find any more modules to link this time, we are done. if (Modules.empty()) @@ -195,14 +198,13 @@ bool llvm::LinkInArchive(Module *M, for (std::set<ModuleProvider*>::iterator I=Modules.begin(), E=Modules.end(); I != E; ++I) { // Get the module we must link in. - std::auto_ptr<Module> aModule((*I)->releaseModule()); + std::auto_ptr<Module> AutoModule( (*I)->releaseModule() ); + + Module* aModule = AutoModule.get(); - // Link it in. - if (LinkModules(M, aModule.get(), ErrorMessage)) { - // don't create a memory leak - delete arch; + // Link it in + if (LinkModules(M, aModule, ErrorMessage)) return true; // Couldn't link in the right object file... - } } // We have linked in a set of modules determined by the archive to satisfy |