]> granicus.if.org Git - clang/commitdiff
Report more memory using in Preprocessor::getTotalMemory() and PreprocessingRecord...
authorTed Kremenek <kremenek@apple.com>
Tue, 26 Jul 2011 21:17:24 +0000 (21:17 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 26 Jul 2011 21:17:24 +0000 (21:17 +0000)
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

include/clang/Lex/PreprocessingRecord.h
lib/Lex/PreprocessingRecord.cpp
lib/Lex/Preprocessor.cpp

index f454ca96cae4841a9ac407b02de3cbd88bec79f9..b21e8e0374b4bb35108c123f94aff381f7887cc9 100644 (file)
@@ -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;
index 55ae5dc2335a8f033c7b4c9086970de19eb9ca1e..2646c04dd5527aa359e4d4027e2393f7e322689e 100644 (file)
@@ -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();
+}
index a5e86bdfe7a13a7bde08df50b8e98b85bd1d36e3..4431684216f022deb2ab6f9f8c2aa13a9aca4301 100644 (file)
@@ -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