Path: blob/main/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/StringsAndChecksums.cpp
35271 views
//===- StringsAndChecksums.cpp --------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "llvm/DebugInfo/CodeView/StringsAndChecksums.h"9#include "llvm/DebugInfo/CodeView/CodeView.h"10#include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"11#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"12#include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"13#include "llvm/Support/Error.h"14#include <cassert>1516using namespace llvm;17using namespace llvm::codeview;1819StringsAndChecksumsRef::StringsAndChecksumsRef() = default;2021StringsAndChecksumsRef::StringsAndChecksumsRef(22const DebugStringTableSubsectionRef &Strings)23: Strings(&Strings) {}2425StringsAndChecksumsRef::StringsAndChecksumsRef(26const DebugStringTableSubsectionRef &Strings,27const DebugChecksumsSubsectionRef &Checksums)28: Strings(&Strings), Checksums(&Checksums) {}2930void StringsAndChecksumsRef::initializeStrings(31const DebugSubsectionRecord &SR) {32assert(SR.kind() == DebugSubsectionKind::StringTable);33assert(!Strings && "Found a string table even though we already have one!");3435OwnedStrings = std::make_shared<DebugStringTableSubsectionRef>();36consumeError(OwnedStrings->initialize(SR.getRecordData()));37Strings = OwnedStrings.get();38}3940void StringsAndChecksumsRef::reset() {41resetStrings();42resetChecksums();43}4445void StringsAndChecksumsRef::resetStrings() {46OwnedStrings.reset();47Strings = nullptr;48}4950void StringsAndChecksumsRef::resetChecksums() {51OwnedChecksums.reset();52Checksums = nullptr;53}5455void StringsAndChecksumsRef::setStrings(56const DebugStringTableSubsectionRef &StringsRef) {57OwnedStrings = std::make_shared<DebugStringTableSubsectionRef>();58*OwnedStrings = StringsRef;59Strings = OwnedStrings.get();60}6162void StringsAndChecksumsRef::setChecksums(63const DebugChecksumsSubsectionRef &CS) {64OwnedChecksums = std::make_shared<DebugChecksumsSubsectionRef>();65*OwnedChecksums = CS;66Checksums = OwnedChecksums.get();67}6869void StringsAndChecksumsRef::initializeChecksums(70const DebugSubsectionRecord &FCR) {71assert(FCR.kind() == DebugSubsectionKind::FileChecksums);72if (Checksums)73return;7475OwnedChecksums = std::make_shared<DebugChecksumsSubsectionRef>();76consumeError(OwnedChecksums->initialize(FCR.getRecordData()));77Checksums = OwnedChecksums.get();78}798081