[cfe-commits] r48357 - in /cfe/trunk: Lex/Preprocessor.cpp include/clang/Lex/Preprocessor.h

Chris Lattner sabre at nondot.org
Thu Mar 13 23:07:05 PDT 2008


Author: lattner
Date: Fri Mar 14 01:07:05 2008
New Revision: 48357

URL: http://llvm.org/viewvc/llvm-project?rev=48357&view=rev
Log:
Make the preprocessor own its PPCallbacks, fixing a memory leak.
Patch by Sam Bishop!

Modified:
    cfe/trunk/Lex/Preprocessor.cpp
    cfe/trunk/include/clang/Lex/Preprocessor.h

Modified: cfe/trunk/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Lex/Preprocessor.cpp?rev=48357&r1=48356&r2=48357&view=diff

==============================================================================
--- cfe/trunk/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/Lex/Preprocessor.cpp Fri Mar 14 01:07:05 2008
@@ -109,6 +109,8 @@
 
   // Delete the scratch buffer info.
   delete ScratchBuf;
+
+  delete Callbacks;
 }
 
 /// Diag - Forwarding function for diagnostics.  This emits a diagnostic at

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=48357&r1=48356&r2=48357&view=diff

==============================================================================
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Fri Mar 14 01:07:05 2008
@@ -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 @@
   /// 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;
   }
   





More information about the cfe-commits mailing list