use an autoptr
authorChris Lattner <sabre@nondot.org>
Tue, 16 Nov 2004 06:40:54 +0000 (06:40 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 16 Nov 2004 06:40:54 +0000 (06:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17875 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Linker/LinkArchives.cpp

index 11d242ac2c667aa8a7f9d14f6d0fee4749249e33..2cccc983ecdc8577d2ed4198a0c8818533c413dc 100644 (file)
@@ -195,18 +195,14 @@ 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.
-      Module* aModule = (*I)->releaseModule();
+      std::auto_ptr<Module> aModule((*I)->releaseModule());
 
-      // Link it in
-      if (LinkModules(M, aModule, ErrorMessage)) {
+      // Link it in.
+      if (LinkModules(M, aModule.get(), ErrorMessage)) {
         // don't create a memory leak
-        delete aModule;
         delete arch;
         return true;   // Couldn't link in the right object file...        
       }
-        
-      // Since we have linked in this object, throw it away now.
-      delete aModule;
     }
 
     // We have linked in a set of modules determined by the archive to satisfy