]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/DebugInfo/CodeView/StringsAndChecksums.cpp
Merge llvm, clang, lld, lldb, compiler-rt and libc++ r305575, and update
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / DebugInfo / CodeView / StringsAndChecksums.cpp
1 //===- StringsAndChecksums.cpp ----------------------------------*- 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 #include "llvm/DebugInfo/CodeView/StringsAndChecksums.h"
11 #include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"
12 #include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
13 #include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
14
15 using namespace llvm;
16 using namespace llvm::codeview;
17
18 StringsAndChecksumsRef::StringsAndChecksumsRef() {}
19
20 StringsAndChecksumsRef::StringsAndChecksumsRef(
21     const DebugStringTableSubsectionRef &Strings)
22     : Strings(&Strings) {}
23
24 StringsAndChecksumsRef::StringsAndChecksumsRef(
25     const DebugStringTableSubsectionRef &Strings,
26     const DebugChecksumsSubsectionRef &Checksums)
27     : Strings(&Strings), Checksums(&Checksums) {}
28
29 void StringsAndChecksumsRef::initializeStrings(
30     const DebugSubsectionRecord &SR) {
31   assert(SR.kind() == DebugSubsectionKind::StringTable);
32   assert(!Strings && "Found a string table even though we already have one!");
33
34   OwnedStrings = llvm::make_unique<DebugStringTableSubsectionRef>();
35   consumeError(OwnedStrings->initialize(SR.getRecordData()));
36   Strings = OwnedStrings.get();
37 }
38
39 void StringsAndChecksumsRef::setChecksums(
40     const DebugChecksumsSubsectionRef &CS) {
41   OwnedChecksums = llvm::make_unique<DebugChecksumsSubsectionRef>();
42   *OwnedChecksums = CS;
43   Checksums = OwnedChecksums.get();
44 }
45
46 void StringsAndChecksumsRef::initializeChecksums(
47     const DebugSubsectionRecord &FCR) {
48   assert(FCR.kind() == DebugSubsectionKind::FileChecksums);
49   if (Checksums)
50     return;
51
52   OwnedChecksums = llvm::make_unique<DebugChecksumsSubsectionRef>();
53   consumeError(OwnedChecksums->initialize(FCR.getRecordData()));
54   Checksums = OwnedChecksums.get();
55 }