diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-07-26 21:17:24 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-07-26 21:17:24 +0000 |
commit | 91d1bd6ede1d101a2e49719250c33154b39e0016 (patch) | |
tree | 7c549d6ee31d9ba17121d511a141765eafc695a6 | |
parent | bb9d3f1b00aabf3156a431b2a0db21509b235505 (diff) |
Report more memory using in Preprocessor::getTotalMemory() and PreprocessingRecord::getTotalMemory().
Most of the memory was already reported; but now we report more memory from side data structures.
Fixes <rdar://problem/9379717>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136150 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Lex/PreprocessingRecord.h | 8 | ||||
-rw-r--r-- | lib/Lex/PreprocessingRecord.cpp | 7 | ||||
-rw-r--r-- | lib/Lex/Preprocessor.cpp | 8 |
3 files changed, 17 insertions, 6 deletions
diff --git a/include/clang/Lex/PreprocessingRecord.h b/include/clang/Lex/PreprocessingRecord.h index f454ca96ca..b21e8e0374 100644 --- a/include/clang/Lex/PreprocessingRecord.h +++ b/include/clang/Lex/PreprocessingRecord.h @@ -298,11 +298,9 @@ namespace clang { /// \brief Deallocate memory in the preprocessing record. void Deallocate(void *Ptr) { } - - size_t getTotalMemory() const { - return BumpAlloc.getTotalMemory(); - } - + + size_t getTotalMemory() const; + // Iteration over the preprocessed entities. class iterator { PreprocessingRecord *Self; diff --git a/lib/Lex/PreprocessingRecord.cpp b/lib/Lex/PreprocessingRecord.cpp index 55ae5dc233..2646c04dd5 100644 --- a/lib/Lex/PreprocessingRecord.cpp +++ b/lib/Lex/PreprocessingRecord.cpp @@ -174,3 +174,10 @@ void PreprocessingRecord::InclusionDirective( File, SourceRange(HashLoc, EndLoc)); PreprocessedEntities.push_back(ID); } + +size_t PreprocessingRecord::getTotalMemory() const { + return BumpAlloc.getTotalMemory() + + MacroDefinitions.getMemorySize() + + PreprocessedEntities.capacity() + + LoadedPreprocessedEntities.capacity(); +} diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp index a5e86bdfe7..4431684216 100644 --- a/lib/Lex/Preprocessor.cpp +++ b/lib/Lex/Preprocessor.cpp @@ -228,7 +228,13 @@ Preprocessor::macro_begin(bool IncludeExternalMacros) const { } size_t Preprocessor::getTotalMemory() const { - return BP.getTotalMemory() + MacroExpandedTokens.capacity()*sizeof(Token); + return BP.getTotalMemory() + + MacroExpandedTokens.capacity() + + Predefines.capacity() /* Predefines buffer. */ + + Macros.getMemorySize() + + PragmaPushMacroInfo.getMemorySize() + + PoisonReasons.getMemorySize() + + CommentHandlers.capacity(); } Preprocessor::macro_iterator |