diff options
author | Chris Lattner <sabre@nondot.org> | 2009-12-15 01:51:03 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-12-15 01:51:03 +0000 |
commit | 23f77e59718385512984d4e2a021bef52b9f6ddf (patch) | |
tree | 89efca14655a462a16c1c4dc8d9b082dc36ba901 /lib/Lex/MacroArgs.cpp | |
parent | c768a0c46e6c064c3281d663777ee95aea8652ee (diff) |
set up the machinery for a MacroArgs cache hanging off Preprocessor.
We creating and free thousands of MacroArgs objects (and the related
std::vectors hanging off them) for the testcase in PR5610 even though
there are only ~20 live at a time. This doesn't actually use the
cache yet.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91391 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/MacroArgs.cpp')
-rw-r--r-- | lib/Lex/MacroArgs.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/Lex/MacroArgs.cpp b/lib/Lex/MacroArgs.cpp index a621854814..376cce8eb3 100644 --- a/lib/Lex/MacroArgs.cpp +++ b/lib/Lex/MacroArgs.cpp @@ -48,6 +48,19 @@ void MacroArgs::destroy(Preprocessor &PP) { free(this); } +/// deallocate - This should only be called by the Preprocessor when managing +/// its freelist. +MacroArgs *MacroArgs::deallocate() { + MacroArgs *Next = ArgCache; + + // Run the dtor to deallocate the vectors. + this->~MacroArgs(); + // Release the memory for the object. + free(this); + + return Next; +} + /// getArgLength - Given a pointer to an expanded or unexpanded argument, /// return the number of tokens, not counting the EOF, that make up the |