9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_SUPPORT_MEMORYTREE_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_SUPPORT_MEMORYTREE_H
13#include "llvm/ADT/DenseMap.h"
14#include "llvm/ADT/StringRef.h"
15#include "llvm/Support/Allocator.h"
33 MemoryTree(llvm::BumpPtrAllocator *DetailAlloc =
nullptr)
34 : DetailAlloc(DetailAlloc) {}
52 return DetailAlloc ? createChild(
Name.copy(*DetailAlloc)) : *
this;
56 void addUsage(
size_t Increment) { Size += Increment; }
59 const llvm::DenseMap<llvm::StringRef, MemoryTree> &
children()
const;
65 size_t self()
const {
return Size; }
73 llvm::BumpPtrAllocator *DetailAlloc =
nullptr;
79 llvm::DenseMap<llvm::StringRef, MemoryTree> Children;
84void record(
const MemoryTree &MT, std::string RootName,
85 const trace::Metric &
Out);
llvm::SmallString< 256U > Name
CompiledFragmentImpl & Out
void record(const MemoryTree &MT, std::string RootName, const trace::Metric &Out)
Records total memory usage of each node under Out.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
A tree that can be used to represent memory usage of nested components while preserving the hierarchy...
MemoryTree & operator=(const MemoryTree &)=delete
size_t total() const
Returns total number of bytes used by this sub-tree. Performs a traversal.
MemoryTree(llvm::BumpPtrAllocator *DetailAlloc=nullptr)
If Alloc is nullptr, tree is in brief mode and will ignore detail edges.
MemoryTree(const MemoryTree &)=delete
const llvm::DenseMap< llvm::StringRef, MemoryTree > & children() const
Returns edges to direct children of this node.
MemoryTree(MemoryTree &&)=default
void addUsage(size_t Increment)
Increases size of current node by Increment.
MemoryTree & child(llvm::StringLiteral Name)
No copy of the Name.
MemoryTree & operator=(MemoryTree &&)=default
MemoryTree & detail(llvm::StringRef Name)
Makes a copy of the Name in detailed mode, returns current node otherwise.
size_t self() const
Returns total number of bytes used by this node only.