1 //===- FileEntry.h ----------------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_DEBUGINFO_GSYM_FILEENTRY_H
10 #define LLVM_DEBUGINFO_GSYM_FILEENTRY_H
12 #include "llvm/ADT/DenseMapInfo.h"
13 #include "llvm/ADT/Hashing.h"
21 /// Files in GSYM are contained in FileEntry structs where we split the
22 /// directory and basename into two different strings in the string
23 /// table. This allows paths to shared commont directory and filename
24 /// strings and saves space.
27 /// Offsets in the string table.
33 FileEntry() = default;
34 FileEntry(uint32_t D
, uint32_t B
) : Dir(D
), Base(B
) {}
36 // Implement operator== so that FileEntry can be used as key in
37 // unordered containers.
38 bool operator==(const FileEntry
&RHS
) const {
39 return Base
== RHS
.Base
&& Dir
== RHS
.Dir
;
41 bool operator!=(const FileEntry
&RHS
) const {
42 return Base
!= RHS
.Base
|| Dir
!= RHS
.Dir
;
48 template <> struct DenseMapInfo
<gsym::FileEntry
> {
49 static inline gsym::FileEntry
getEmptyKey() {
50 uint32_t key
= DenseMapInfo
<uint32_t>::getEmptyKey();
51 return gsym::FileEntry(key
, key
);
53 static inline gsym::FileEntry
getTombstoneKey() {
54 uint32_t key
= DenseMapInfo
<uint32_t>::getTombstoneKey();
55 return gsym::FileEntry(key
, key
);
57 static unsigned getHashValue(const gsym::FileEntry
&Val
) {
58 return llvm::hash_combine(DenseMapInfo
<uint32_t>::getHashValue(Val
.Dir
),
59 DenseMapInfo
<uint32_t>::getHashValue(Val
.Base
));
61 static bool isEqual(const gsym::FileEntry
&LHS
, const gsym::FileEntry
&RHS
) {
67 #endif // #ifndef LLVM_DEBUGINFO_GSYM_FILEENTRY_H