Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 14 | pmbaty | 1 | //===- FileEntry.h ----------------------------------------------*- C++ -*-===// |
| 2 | // |
||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
||
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
||
| 6 | // |
||
| 7 | //===----------------------------------------------------------------------===// |
||
| 8 | |||
| 9 | #ifndef LLVM_DEBUGINFO_GSYM_FILEENTRY_H |
||
| 10 | #define LLVM_DEBUGINFO_GSYM_FILEENTRY_H |
||
| 11 | |||
| 12 | #include "llvm/ADT/DenseMapInfo.h" |
||
| 13 | #include "llvm/ADT/Hashing.h" |
||
| 14 | #include <functional> |
||
| 15 | #include <stdint.h> |
||
| 16 | |||
| 17 | namespace llvm { |
||
| 18 | namespace gsym { |
||
| 19 | |||
| 20 | /// Files in GSYM are contained in FileEntry structs where we split the |
||
| 21 | /// directory and basename into two different strings in the string |
||
| 22 | /// table. This allows paths to shared commont directory and filename |
||
| 23 | /// strings and saves space. |
||
| 24 | struct FileEntry { |
||
| 25 | |||
| 26 | /// Offsets in the string table. |
||
| 27 | /// @{ |
||
| 28 | uint32_t Dir = 0; |
||
| 29 | uint32_t Base = 0; |
||
| 30 | /// @} |
||
| 31 | |||
| 32 | FileEntry() = default; |
||
| 33 | FileEntry(uint32_t D, uint32_t B) : Dir(D), Base(B) {} |
||
| 34 | |||
| 35 | // Implement operator== so that FileEntry can be used as key in |
||
| 36 | // unordered containers. |
||
| 37 | bool operator==(const FileEntry &RHS) const { |
||
| 38 | return Base == RHS.Base && Dir == RHS.Dir; |
||
| 39 | }; |
||
| 40 | bool operator!=(const FileEntry &RHS) const { |
||
| 41 | return Base != RHS.Base || Dir != RHS.Dir; |
||
| 42 | }; |
||
| 43 | }; |
||
| 44 | |||
| 45 | } // namespace gsym |
||
| 46 | |||
| 47 | template <> struct DenseMapInfo<gsym::FileEntry> { |
||
| 48 | static inline gsym::FileEntry getEmptyKey() { |
||
| 49 | uint32_t key = DenseMapInfo<uint32_t>::getEmptyKey(); |
||
| 50 | return gsym::FileEntry(key, key); |
||
| 51 | } |
||
| 52 | static inline gsym::FileEntry getTombstoneKey() { |
||
| 53 | uint32_t key = DenseMapInfo<uint32_t>::getTombstoneKey(); |
||
| 54 | return gsym::FileEntry(key, key); |
||
| 55 | } |
||
| 56 | static unsigned getHashValue(const gsym::FileEntry &Val) { |
||
| 57 | return llvm::hash_combine(DenseMapInfo<uint32_t>::getHashValue(Val.Dir), |
||
| 58 | DenseMapInfo<uint32_t>::getHashValue(Val.Base)); |
||
| 59 | } |
||
| 60 | static bool isEqual(const gsym::FileEntry &LHS, const gsym::FileEntry &RHS) { |
||
| 61 | return LHS == RHS; |
||
| 62 | } |
||
| 63 | }; |
||
| 64 | |||
| 65 | } // namespace llvm |
||
| 66 | #endif // LLVM_DEBUGINFO_GSYM_FILEENTRY_H |