summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2011-07-26 21:17:24 +0000
committerTed Kremenek <kremenek@apple.com>2011-07-26 21:17:24 +0000
commit182543aba2ab09cd3e3c1cf8c6a9ca25245b93c0 (patch)
tree7b689ec73f82534e4ef6308c901fbc14a03094b8 /clang
parent93dc04d5ca5244877eeee6cb2249475271b47f30 (diff)
downloadbcm5719-llvm-182543aba2ab09cd3e3c1cf8c6a9ca25245b93c0.tar.gz
bcm5719-llvm-182543aba2ab09cd3e3c1cf8c6a9ca25245b93c0.zip
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>. llvm-svn: 136150
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/Lex/PreprocessingRecord.h8
-rw-r--r--clang/lib/Lex/PreprocessingRecord.cpp7
-rw-r--r--clang/lib/Lex/Preprocessor.cpp8
3 files changed, 17 insertions, 6 deletions
diff --git a/clang/include/clang/Lex/PreprocessingRecord.h b/clang/include/clang/Lex/PreprocessingRecord.h
index f454ca96cae..b21e8e0374b 100644
--- a/clang/include/clang/Lex/PreprocessingRecord.h
+++ b/clang/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/clang/lib/Lex/PreprocessingRecord.cpp b/clang/lib/Lex/PreprocessingRecord.cpp
index 55ae5dc2335..2646c04dd55 100644
--- a/clang/lib/Lex/PreprocessingRecord.cpp
+++ b/clang/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/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp
index a5e86bdfe7a..4431684216f 100644
--- a/clang/lib/Lex/Preprocessor.cpp
+++ b/clang/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
OpenPOWER on IntegriCloud