diff options
| author | Chris Lattner <sabre@nondot.org> | 2008-03-14 06:07:05 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2008-03-14 06:07:05 +0000 |
| commit | 221929310b192abc79140318fb9801760e76a928 (patch) | |
| tree | f77d8396c2755d48f0c37da2d931682c2383238a /clang | |
| parent | 477d0f5294539c3fbbbaaac3c0c6005098de00d2 (diff) | |
| download | bcm5719-llvm-221929310b192abc79140318fb9801760e76a928.tar.gz bcm5719-llvm-221929310b192abc79140318fb9801760e76a928.zip | |
Make the preprocessor own its PPCallbacks, fixing a memory leak.
Patch by Sam Bishop!
llvm-svn: 48357
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/Lex/Preprocessor.cpp | 2 | ||||
| -rw-r--r-- | clang/include/clang/Lex/Preprocessor.h | 7 |
2 files changed, 7 insertions, 2 deletions
diff --git a/clang/Lex/Preprocessor.cpp b/clang/Lex/Preprocessor.cpp index 79b0d62edbe..86156a07728 100644 --- a/clang/Lex/Preprocessor.cpp +++ b/clang/Lex/Preprocessor.cpp @@ -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 diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h index 717f865b60b..98edf5af7a8 100644 --- a/clang/include/clang/Lex/Preprocessor.h +++ b/clang/include/clang/Lex/Preprocessor.h @@ -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; } |

