llvm/clang-tools-extra/clangd/support/MemoryTree.h

//===--- MemoryTree.h - A special tree for components and sizes -*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_SUPPORT_MEMORYTREE_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_SUPPORT_MEMORYTREE_H

#include "Trace.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Allocator.h"
#include <cstddef>
#include <string>
#include <vector>

namespace clang {
namespace clangd {

/// 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.
struct MemoryTree {};

/// Records total memory usage of each node under \p Out. Labels are edges on
/// the path joined with ".", starting with \p RootName.
void record(const MemoryTree &MT, std::string RootName,
            const trace::Metric &Out);

} // namespace clangd
} // namespace clang

#endif