[llvm-shlib] Fix the version naming style of libLLVM for Windows (#85710)
[llvm-project.git] / llvm / lib / DebugInfo / CodeView / StringsAndChecksums.cpp
blob81aa44fb2086f8fdfccd814e114a16e8ef752b53
1 //===- StringsAndChecksums.cpp --------------------------------------------===//
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 //===----------------------------------------------------------------------===//
9 #include "llvm/DebugInfo/CodeView/StringsAndChecksums.h"
10 #include "llvm/DebugInfo/CodeView/CodeView.h"
11 #include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"
12 #include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
13 #include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
14 #include "llvm/Support/Error.h"
15 #include <cassert>
17 using namespace llvm;
18 using namespace llvm::codeview;
20 StringsAndChecksumsRef::StringsAndChecksumsRef() = default;
22 StringsAndChecksumsRef::StringsAndChecksumsRef(
23 const DebugStringTableSubsectionRef &Strings)
24 : Strings(&Strings) {}
26 StringsAndChecksumsRef::StringsAndChecksumsRef(
27 const DebugStringTableSubsectionRef &Strings,
28 const DebugChecksumsSubsectionRef &Checksums)
29 : Strings(&Strings), Checksums(&Checksums) {}
31 void StringsAndChecksumsRef::initializeStrings(
32 const DebugSubsectionRecord &SR) {
33 assert(SR.kind() == DebugSubsectionKind::StringTable);
34 assert(!Strings && "Found a string table even though we already have one!");
36 OwnedStrings = std::make_shared<DebugStringTableSubsectionRef>();
37 consumeError(OwnedStrings->initialize(SR.getRecordData()));
38 Strings = OwnedStrings.get();
41 void StringsAndChecksumsRef::reset() {
42 resetStrings();
43 resetChecksums();
46 void StringsAndChecksumsRef::resetStrings() {
47 OwnedStrings.reset();
48 Strings = nullptr;
51 void StringsAndChecksumsRef::resetChecksums() {
52 OwnedChecksums.reset();
53 Checksums = nullptr;
56 void StringsAndChecksumsRef::setStrings(
57 const DebugStringTableSubsectionRef &StringsRef) {
58 OwnedStrings = std::make_shared<DebugStringTableSubsectionRef>();
59 *OwnedStrings = StringsRef;
60 Strings = OwnedStrings.get();
63 void StringsAndChecksumsRef::setChecksums(
64 const DebugChecksumsSubsectionRef &CS) {
65 OwnedChecksums = std::make_shared<DebugChecksumsSubsectionRef>();
66 *OwnedChecksums = CS;
67 Checksums = OwnedChecksums.get();
70 void StringsAndChecksumsRef::initializeChecksums(
71 const DebugSubsectionRecord &FCR) {
72 assert(FCR.kind() == DebugSubsectionKind::FileChecksums);
73 if (Checksums)
74 return;
76 OwnedChecksums = std::make_shared<DebugChecksumsSubsectionRef>();
77 consumeError(OwnedChecksums->initialize(FCR.getRecordData()));
78 Checksums = OwnedChecksums.get();