1 //===- StringsAndChecksums.cpp --------------------------------------------===//
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 #include "llvm/DebugInfo/CodeView/StringsAndChecksums.h"
10 #include "llvm/ADT/STLExtras.h"
11 #include "llvm/DebugInfo/CodeView/CodeView.h"
12 #include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"
13 #include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
14 #include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
15 #include "llvm/Support/Error.h"
19 using namespace llvm::codeview
;
21 StringsAndChecksumsRef::StringsAndChecksumsRef() = default;
23 StringsAndChecksumsRef::StringsAndChecksumsRef(
24 const DebugStringTableSubsectionRef
&Strings
)
25 : Strings(&Strings
) {}
27 StringsAndChecksumsRef::StringsAndChecksumsRef(
28 const DebugStringTableSubsectionRef
&Strings
,
29 const DebugChecksumsSubsectionRef
&Checksums
)
30 : Strings(&Strings
), Checksums(&Checksums
) {}
32 void StringsAndChecksumsRef::initializeStrings(
33 const DebugSubsectionRecord
&SR
) {
34 assert(SR
.kind() == DebugSubsectionKind::StringTable
);
35 assert(!Strings
&& "Found a string table even though we already have one!");
37 OwnedStrings
= std::make_shared
<DebugStringTableSubsectionRef
>();
38 consumeError(OwnedStrings
->initialize(SR
.getRecordData()));
39 Strings
= OwnedStrings
.get();
42 void StringsAndChecksumsRef::reset() {
47 void StringsAndChecksumsRef::resetStrings() {
52 void StringsAndChecksumsRef::resetChecksums() {
53 OwnedChecksums
.reset();
57 void StringsAndChecksumsRef::setStrings(
58 const DebugStringTableSubsectionRef
&StringsRef
) {
59 OwnedStrings
= std::make_shared
<DebugStringTableSubsectionRef
>();
60 *OwnedStrings
= StringsRef
;
61 Strings
= OwnedStrings
.get();
64 void StringsAndChecksumsRef::setChecksums(
65 const DebugChecksumsSubsectionRef
&CS
) {
66 OwnedChecksums
= std::make_shared
<DebugChecksumsSubsectionRef
>();
68 Checksums
= OwnedChecksums
.get();
71 void StringsAndChecksumsRef::initializeChecksums(
72 const DebugSubsectionRecord
&FCR
) {
73 assert(FCR
.kind() == DebugSubsectionKind::FileChecksums
);
77 OwnedChecksums
= std::make_shared
<DebugChecksumsSubsectionRef
>();
78 consumeError(OwnedChecksums
->initialize(FCR
.getRecordData()));
79 Checksums
= OwnedChecksums
.get();