diff options
-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 |