Go to the documentation of this file.
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;
84 void record(
const MemoryTree &MT, std::string RootName,
85 const trace::Metric &
Out);
MemoryTree & child(llvm::StringLiteral Name)
No copy of the Name.
size_t total() const
Returns total number of bytes used by this sub-tree. Performs a traversal.
MemoryTree & detail(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.
A tree that can be used to represent memory usage of nested components while preserving the hierarchy...
const llvm::DenseMap< llvm::StringRef, MemoryTree > & children() const
Returns edges to direct children of this node.
MemoryTree & operator=(const MemoryTree &)=delete
MemoryTree(llvm::BumpPtrAllocator *DetailAlloc=nullptr)
If Alloc is nullptr, tree is in brief mode and will ignore detail edges.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
void record(const MemoryTree &MT, std::string RootName, const trace::Metric &Out)
Records total memory usage of each node under Out.
CompiledFragmentImpl & Out