//===- DWARFLinkerDeclContext.h ---------------------------------*- 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_DWARFLINKER_CLASSIC_DWARFLINKERDECLCONTEXT_H #define LLVM_DWARFLINKER_CLASSIC_DWARFLINKERDECLCONTEXT_H #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseMapInfo.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/StringRef.h" #include "llvm/CodeGen/NonRelocatableStringpool.h" #include "llvm/DebugInfo/DWARF/DWARFDebugLine.h" #include "llvm/DebugInfo/DWARF/DWARFDie.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" #include <atomic> namespace llvm { namespace dwarf_linker { namespace classic { class CompileUnit; struct DeclMapInfo; /// Small helper that resolves and caches file paths. This helps reduce the /// number of calls to realpath which is expensive. We assume the input are /// files, and cache the realpath of their parent. This way we can quickly /// resolve different files under the same path. class CachedPathResolver { … }; /// A DeclContext is a named program scope that is used for ODR uniquing of /// types. /// /// The set of DeclContext for the ODR-subject parts of a Dwarf link is /// expanded (and uniqued) with each new object file processed. We need to /// determine the context of each DIE in an linked object file to see if the /// corresponding type has already been emitted. /// /// The contexts are conceptually organized as a tree (eg. a function scope is /// contained in a namespace scope that contains other scopes), but /// storing/accessing them in an actual tree is too inefficient: we need to be /// able to very quickly query a context for a given child context by name. /// Storing a StringMap in each DeclContext would be too space inefficient. /// /// The solution here is to give each DeclContext a link to its parent (this /// allows to walk up the tree), but to query the existence of a specific /// DeclContext using a separate DenseMap keyed on the hash of the fully /// qualified name of the context. class DeclContext { … }; /// This class gives a tree-like API to the DenseMap that stores the /// DeclContext objects. It holds the BumpPtrAllocator where these objects will /// be allocated. class DeclContextTree { … }; /// Info type for the DenseMap storing the DeclContext pointers. struct DeclMapInfo : private DenseMapInfo<DeclContext *> { … }; } // end of namespace classic } // end of namespace dwarf_linker } // end of namespace llvm #endif // LLVM_DWARFLINKER_CLASSIC_DWARFLINKERDECLCONTEXT_H