From: Ted Kremenek Date: Tue, 26 Jul 2011 21:17:24 +0000 (+0000) Subject: Report more memory using in Preprocessor::getTotalMemory() and PreprocessingRecord... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=91d1bd6ede1d101a2e49719250c33154b39e0016;p=clang 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 . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136150 91177308-0d34-0410-b5e6-96231b3b80d8 --- 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