clang-tools  14.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. More...
 
MemoryTreechild (llvm::StringLiteral Name)
 No copy of the Name. More...
 
 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. More...
 
void addUsage (size_t Increment)
 Increases size of current node by Increment. More...
 
const llvm::DenseMap< llvm::StringRef, MemoryTree > & children () const
 Returns edges to direct children of this node. More...
 
size_t total () const
 Returns total number of bytes used by this sub-tree. Performs a traversal. More...
 
size_t self () const
 Returns total number of bytes used by this node only. More...
 

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 32 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 35 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 41 of file MemoryTree.h.

References Name.

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

◆ children()

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

Returns edges to direct children of this node.

Definition at line 35 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 53 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 67 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 39 of file MemoryTree.cpp.

References Total.


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