[cfe-commits] r136150 - in /cfe/trunk: include/clang/Lex/PreprocessingRecord.h lib/Lex/PreprocessingRecord.cpp lib/Lex/Preprocessor.cpp

Ted Kremenek kremenek at apple.com
Tue Jul 26 14:17:24 PDT 2011


Author: kremenek
Date: Tue Jul 26 16:17:24 2011
New Revision: 136150

URL: http://llvm.org/viewvc/llvm-project?rev=136150&view=rev
Log:
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>.

Modified:
    cfe/trunk/include/clang/Lex/PreprocessingRecord.h
    cfe/trunk/lib/Lex/PreprocessingRecord.cpp
    cfe/trunk/lib/Lex/Preprocessor.cpp

Modified: cfe/trunk/include/clang/Lex/PreprocessingRecord.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PreprocessingRecord.h?rev=136150&r1=136149&r2=136150&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/PreprocessingRecord.h (original)
+++ cfe/trunk/include/clang/Lex/PreprocessingRecord.h Tue Jul 26 16:17:24 2011
@@ -298,11 +298,9 @@
     
     /// \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;

Modified: cfe/trunk/lib/Lex/PreprocessingRecord.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PreprocessingRecord.cpp?rev=136150&r1=136149&r2=136150&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PreprocessingRecord.cpp (original)
+++ cfe/trunk/lib/Lex/PreprocessingRecord.cpp Tue Jul 26 16:17:24 2011
@@ -174,3 +174,10 @@
                                             File, SourceRange(HashLoc, EndLoc));
   PreprocessedEntities.push_back(ID);
 }
+
+size_t PreprocessingRecord::getTotalMemory() const {
+  return BumpAlloc.getTotalMemory()
+    + MacroDefinitions.getMemorySize()
+    + PreprocessedEntities.capacity()
+    + LoadedPreprocessedEntities.capacity();
+}

Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=136150&r1=136149&r2=136150&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Tue Jul 26 16:17:24 2011
@@ -228,7 +228,13 @@
 }
 
 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





More information about the cfe-commits mailing list