]> granicus.if.org Git - clang/commitdiff
Make the preprocessor own its PPCallbacks, fixing a memory leak.
authorChris Lattner <sabre@nondot.org>
Fri, 14 Mar 2008 06:07:05 +0000 (06:07 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 14 Mar 2008 06:07:05 +0000 (06:07 +0000)
Patch by Sam Bishop!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48357 91177308-0d34-0410-b5e6-96231b3b80d8

Lex/Preprocessor.cpp
include/clang/Lex/Preprocessor.h

index 79b0d62edbe9b79f8b38a6649c0689a309cec138..86156a07728ed8c3809aa4b2b26ffef53826d5f9 100644 (file)
@@ -109,6 +109,8 @@ Preprocessor::~Preprocessor() {
 
   // Delete the scratch buffer info.
   delete ScratchBuf;
+
+  delete Callbacks;
 }
 
 /// Diag - Forwarding function for diagnostics.  This emits a diagnostic at
index 717f865b60ba9334ba49dad5beef26561675cfdb..98edf5af7a81a3b77ffeafeb148b7284da44eb88 100644 (file)
@@ -15,6 +15,7 @@
 #define LLVM_CLANG_LEX_PREPROCESSOR_H
 
 #include "clang/Lex/Lexer.h"
+#include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/TokenLexer.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/SourceLocation.h"
@@ -176,10 +177,12 @@ public:
   /// expansions going on at the time.
   Lexer *getCurrentFileLexer() const;
   
-  /// getPPCallbacks/SetPPCallbacks - Accessors for preprocessor callbacks.
-  ///
+  /// getPPCallbacks/setPPCallbacks - Accessors for preprocessor callbacks.
+  /// Note that this class takes ownership of any PPCallbacks object given to
+  /// it.
   PPCallbacks *getPPCallbacks() const { return Callbacks; }
   void setPPCallbacks(PPCallbacks *C) {
+    delete Callbacks;
     Callbacks = C;
   }