]> granicus.if.org Git - clang/commitdiff
fix leaking of the module provider
authorNuno Lopes <nunoplopes@sapo.pt>
Fri, 24 Oct 2008 22:51:00 +0000 (22:51 +0000)
committerNuno Lopes <nunoplopes@sapo.pt>
Fri, 24 Oct 2008 22:51:00 +0000 (22:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58127 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/Backend.cpp

index f8cfa997e25c42d4f6c2cc701203c39061353f58..37c5f1651b08c9820e4b1640b5ff1f0e8ffea8bf 100644 (file)
@@ -52,6 +52,7 @@ namespace {
     llvm::TargetData *TheTargetData;
     llvm::raw_ostream *AsmOutStream;
 
+    mutable llvm::ModuleProvider *ModuleProvider;
     mutable FunctionPassManager *CodeGenPasses;
     mutable PassManager *PerModulePasses;
     mutable FunctionPassManager *PerFunctionPasses;
@@ -81,7 +82,7 @@ namespace {
       InputFile(infile), 
       OutputFile(outfile), 
       Gen(CreateLLVMCodeGen(Diags, Features, InputFile, GenerateDebugInfo)),
-      TheModule(0), TheTargetData(0), AsmOutStream(0),
+      TheModule(0), TheTargetData(0), AsmOutStream(0), ModuleProvider(0),
       CodeGenPasses(0), PerModulePasses(0), PerFunctionPasses(0) {}
 
     ~BackendConsumer() {
@@ -91,6 +92,7 @@ namespace {
       delete AsmOutStream;
       delete TheTargetData;
       delete TheModule;
+      delete ModuleProvider;
       delete CodeGenPasses;
       delete PerModulePasses;
       delete PerFunctionPasses;
@@ -120,8 +122,8 @@ namespace {
 
 FunctionPassManager *BackendConsumer::getCodeGenPasses() const {
   if (!CodeGenPasses) {
-    CodeGenPasses = 
-      new FunctionPassManager(new ExistingModuleProvider(TheModule));
+    ModuleProvider = new ExistingModuleProvider(TheModule);
+    CodeGenPasses = new FunctionPassManager(ModuleProvider);
     CodeGenPasses->add(new TargetData(*TheTargetData));
   }