clang-tools 19.0.0git
Public Member Functions | List of all members
clang::clangd::MemoryTree Struct Reference

A tree that can be used to represent memory usage of nested components while preserving the hierarchy. More...

#include <MemoryTree.h>

Public Member Functions

 MemoryTree (llvm::BumpPtrAllocator *DetailAlloc=nullptr)
 If Alloc is nullptr, tree is in brief mode and will ignore detail edges.
 
MemoryTreechild (llvm::StringLiteral Name)
 No copy of the Name.
 
 MemoryTree (const MemoryTree &)=delete
 
MemoryTreeoperator= (const MemoryTree &)=delete
 
 MemoryTree (MemoryTree &&)=default
 
MemoryTreeoperator= (MemoryTree &&)=default
 
MemoryTreedetail (llvm::StringRef Name)
 Makes a copy of the Name in detailed mode, returns current node otherwise.
 
void addUsage (size_t Increment)
 Increases size of current node by Increment.
 
const llvm::DenseMap< llvm::StringRef, MemoryTree > & children () const
 Returns edges to direct children of this node.
 
size_t total () const
 Returns total number of bytes used by this sub-tree. Performs a traversal.
 
size_t self () const
 Returns total number of bytes used by this node only.
 

Detailed Description

A tree that can be used to represent memory usage of nested components while preserving the hierarchy.

Edges have associated names. An edge that might not be interesting to all traversers or costly to copy (e.g. file names) can be marked as "detail". Tree construction allows chosing between a detailed and brief mode, in brief mode all "detail" edges are ignored and tree is constructed without any string copies.

Definition at line 30 of file MemoryTree.h.

Constructor & Destructor Documentation

◆ MemoryTree() [1/3]

clang::clangd::MemoryTree::MemoryTree ( llvm::BumpPtrAllocator *  DetailAlloc = nullptr)
inline

If Alloc is nullptr, tree is in brief mode and will ignore detail edges.

Definition at line 33 of file MemoryTree.h.

◆ MemoryTree() [2/3]

clang::clangd::MemoryTree::MemoryTree ( const MemoryTree )
delete

◆ MemoryTree() [3/3]

clang::clangd::MemoryTree::MemoryTree ( MemoryTree &&  )
default

Member Function Documentation

◆ addUsage()

void clang::clangd::MemoryTree::addUsage ( size_t  Increment)
inline

◆ child()

MemoryTree & clang::clangd::MemoryTree::child ( llvm::StringLiteral  Name)
inline

No copy of the Name.

Note that returned pointers are invalidated with subsequent calls to child/detail.

Definition at line 39 of file MemoryTree.h.

References Name.

Referenced by clang::clangd::ClangdLSPServer::profile(), clang::clangd::ClangdServer::profile(), clang::clangd::BackgroundIndex::profile(), clang::clangd::FileSymbols::profile(), clang::clangd::FileIndex::profile(), and clang::clangd::TUScheduler::profile().

◆ children()

const llvm::DenseMap< llvm::StringRef, MemoryTree > & clang::clangd::MemoryTree::children ( ) const

Returns edges to direct children of this node.

Definition at line 42 of file MemoryTree.cpp.

Referenced by clang::clangd::toJSON().

◆ detail()

MemoryTree & clang::clangd::MemoryTree::detail ( llvm::StringRef  Name)
inline

Makes a copy of the Name in detailed mode, returns current node otherwise.

Note that returned pointers are invalidated with subsequent calls to child/detail.

Definition at line 51 of file MemoryTree.h.

References Name.

Referenced by clang::clangd::FileSymbols::profile(), and clang::clangd::TUScheduler::profile().

◆ operator=() [1/2]

MemoryTree & clang::clangd::MemoryTree::operator= ( const MemoryTree )
delete

◆ operator=() [2/2]

MemoryTree & clang::clangd::MemoryTree::operator= ( MemoryTree &&  )
default

◆ self()

size_t clang::clangd::MemoryTree::self ( ) const
inline

Returns total number of bytes used by this node only.

Definition at line 65 of file MemoryTree.h.

Referenced by clang::clangd::toJSON().

◆ total()

size_t clang::clangd::MemoryTree::total ( ) const

Returns total number of bytes used by this sub-tree. Performs a traversal.

Definition at line 46 of file MemoryTree.cpp.

References Total.


The documentation for this struct was generated from the following files: