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 | eb50ed88c2aa040fac08bf2a50bde4dd3da6eb19 (patch) | |
tree | ff785fac719d6f5549d54fcc56adbb1a72beb4e6 | |
parent | 5af27e02917089dd107c58c1cfdb064544010773 (diff) |
Make the preprocessor own its PPCallbacks, fixing a memory leak.
Patch by Sam Bishop!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48357 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | Lex/Preprocessor.cpp | 2 | ||||
-rw-r--r-- | include/clang/Lex/Preprocessor.h | 7 |
2 files changed, 7 insertions, 2 deletions
diff --git a/Lex/Preprocessor.cpp b/Lex/Preprocessor.cpp index 79b0d62edb..86156a0772 100644 --- a/Lex/Preprocessor.cpp +++ b/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/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h index 717f865b60..98edf5af7a 100644 --- a/include/clang/Lex/Preprocessor.h +++ b/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; } |