[cfe-commits] r136189 - in /cfe/trunk: include/clang-c/Index.h include/clang/Basic/SourceManager.h lib/Basic/SourceManager.cpp tools/libclang/CIndex.cpp

Ted Kremenek kremenek at apple.com
Tue Jul 26 16:46:06 PDT 2011


Author: kremenek
Date: Tue Jul 26 18:46:06 2011
New Revision: 136189

URL: http://llvm.org/viewvc/llvm-project?rev=136189&view=rev
Log:
clang_getCXTUResourceUsage: Report memory used by data structures in SourceManager.

Modified:
    cfe/trunk/include/clang-c/Index.h
    cfe/trunk/include/clang/Basic/SourceManager.h
    cfe/trunk/lib/Basic/SourceManager.cpp
    cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang-c/Index.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=136189&r1=136188&r2=136189&view=diff
==============================================================================
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Tue Jul 26 18:46:06 2011
@@ -1102,12 +1102,13 @@
   CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10, 
   CXTUResourceUsage_Preprocessor = 11,
   CXTUResourceUsage_PreprocessingRecord = 12,
+  CXTUResourceUsage_SourceManager_DataStructures = 13,
   CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST,
   CXTUResourceUsage_MEMORY_IN_BYTES_END =
-    CXTUResourceUsage_PreprocessingRecord,
+    CXTUResourceUsage_SourceManager_DataStructures,
 
   CXTUResourceUsage_First = CXTUResourceUsage_AST,
-  CXTUResourceUsage_Last = CXTUResourceUsage_PreprocessingRecord
+  CXTUResourceUsage_Last = CXTUResourceUsage_SourceManager_DataStructures
 };
 
 /**

Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=136189&r1=136188&r2=136189&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Tue Jul 26 18:46:06 2011
@@ -970,6 +970,10 @@
   /// Return the amount of memory used by memory buffers, breaking down
   /// by heap-backed versus mmap'ed memory.
   MemoryBufferSizes getMemoryBufferSizes() const;
+  
+  // Return the amount of memory used for various side tables and
+  // data structures in the SourceManager.
+  size_t getDataStructureSizes() const;
 
   //===--------------------------------------------------------------------===//
   // Other miscellaneous methods.

Modified: cfe/trunk/lib/Basic/SourceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=136189&r1=136188&r2=136189&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/SourceManager.cpp (original)
+++ cfe/trunk/lib/Basic/SourceManager.cpp Tue Jul 26 18:46:06 2011
@@ -1598,3 +1598,11 @@
   return MemoryBufferSizes(malloc_bytes, mmap_bytes);
 }
 
+size_t SourceManager::getDataStructureSizes() const {
+  return MemBufferInfos.capacity()
+    + LocalSLocEntryTable.capacity()
+    + LoadedSLocEntryTable.capacity()
+    + SLocEntryLoaded.capacity()
+    + FileInfos.getMemorySize()
+    + OverriddenFiles.getMemorySize();
+}

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=136189&r1=136188&r2=136189&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Tue Jul 26 18:46:06 2011
@@ -5455,6 +5455,9 @@
     case CXTUResourceUsage_PreprocessingRecord:
       str = "Preprocessor: PreprocessingRecord";
       break;
+    case CXTUResourceUsage_SourceManager_DataStructures:
+      str = "SourceManager: data structures and tables";
+      break;
   }
   return str;
 }
@@ -5507,9 +5510,13 @@
   createCXTUResourceUsageEntry(*entries,
                                CXTUResourceUsage_SourceManager_Membuffer_Malloc,
                                (unsigned long) srcBufs.malloc_bytes);
-    createCXTUResourceUsageEntry(*entries,
+  createCXTUResourceUsageEntry(*entries,
                                CXTUResourceUsage_SourceManager_Membuffer_MMap,
                                (unsigned long) srcBufs.mmap_bytes);
+  createCXTUResourceUsageEntry(*entries,
+                               CXTUResourceUsage_SourceManager_DataStructures,
+                               (unsigned long) astContext.getSourceManager()
+                                .getDataStructureSizes());
   
   // How much memory is being used by the ExternalASTSource?
   if (ExternalASTSource *esrc = astContext.getExternalSource()) {





More information about the cfe-commits mailing list