1 //==- CodeViewYAMLTypeHashing.h - CodeView YAMLIO Type hashing ----*- C++-*-==//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines classes for handling the YAML representation of CodeView
11 // Debug Info.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_OBJECTYAML_CODEVIEWYAMLTYPEHASHING_H
16 #define LLVM_OBJECTYAML_CODEVIEWYAMLTYPEHASHING_H
17 
18 #include "llvm/ADT/ArrayRef.h"
19 #include "llvm/DebugInfo/CodeView/TypeHashing.h"
20 #include "llvm/ObjectYAML/YAML.h"
21 #include "llvm/Support/Allocator.h"
22 #include "llvm/Support/Error.h"
23 #include "llvm/Support/YAMLTraits.h"
24 #include <cstdint>
25 #include <memory>
26 #include <vector>
27 
28 namespace llvm {
29 
30 namespace CodeViewYAML {
31 
32 struct GlobalHash {
33   GlobalHash() = default;
GlobalHashGlobalHash34   explicit GlobalHash(StringRef S) : Hash(S) {
35     assert(S.size() == 8 && "Invalid hash size!");
36   }
GlobalHashGlobalHash37   explicit GlobalHash(ArrayRef<uint8_t> S) : Hash(S) {
38     assert(S.size() == 8 && "Invalid hash size!");
39   }
40   yaml::BinaryRef Hash;
41 };
42 
43 struct DebugHSection {
44   uint32_t Magic;
45   uint16_t Version;
46   uint16_t HashAlgorithm;
47   std::vector<GlobalHash> Hashes;
48 };
49 
50 DebugHSection fromDebugH(ArrayRef<uint8_t> DebugH);
51 ArrayRef<uint8_t> toDebugH(const DebugHSection &DebugH,
52                            BumpPtrAllocator &Alloc);
53 
54 } // end namespace CodeViewYAML
55 
56 } // end namespace llvm
57 
58 LLVM_YAML_DECLARE_MAPPING_TRAITS(CodeViewYAML::DebugHSection)
59 LLVM_YAML_DECLARE_SCALAR_TRAITS(CodeViewYAML::GlobalHash, QuotingType::None)
60 LLVM_YAML_IS_SEQUENCE_VECTOR(CodeViewYAML::GlobalHash)
61 
62 #endif // LLVM_OBJECTYAML_CODEVIEWYAMLTYPES_H
63