blob: 306af1d1ef6bc660f2af824525de0962f1e424a0 [file] [log] [blame]
Eugene Zelenko4fcfc192017-06-30 23:06:03 +00001//===- StringsAndChecksums.cpp --------------------------------------------===//
Zachary Turnera8cfc292017-06-14 15:59:27 +00002//
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"
Eugene Zelenko4fcfc192017-06-30 23:06:03 +000011#include "llvm/ADT/STLExtras.h"
12#include "llvm/DebugInfo/CodeView/CodeView.h"
Zachary Turnera8cfc292017-06-14 15:59:27 +000013#include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"
14#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
15#include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
Eugene Zelenko4fcfc192017-06-30 23:06:03 +000016#include "llvm/Support/Error.h"
17#include <cassert>
Zachary Turnera8cfc292017-06-14 15:59:27 +000018
19using namespace llvm;
20using namespace llvm::codeview;
21
Eugene Zelenko4fcfc192017-06-30 23:06:03 +000022StringsAndChecksumsRef::StringsAndChecksumsRef() = default;
Zachary Turnera8cfc292017-06-14 15:59:27 +000023
24StringsAndChecksumsRef::StringsAndChecksumsRef(
25 const DebugStringTableSubsectionRef &Strings)
26 : Strings(&Strings) {}
27
28StringsAndChecksumsRef::StringsAndChecksumsRef(
29 const DebugStringTableSubsectionRef &Strings,
30 const DebugChecksumsSubsectionRef &Checksums)
31 : Strings(&Strings), Checksums(&Checksums) {}
32
33void StringsAndChecksumsRef::initializeStrings(
34 const DebugSubsectionRecord &SR) {
35 assert(SR.kind() == DebugSubsectionKind::StringTable);
36 assert(!Strings && "Found a string table even though we already have one!");
37
38 OwnedStrings = llvm::make_unique<DebugStringTableSubsectionRef>();
39 consumeError(OwnedStrings->initialize(SR.getRecordData()));
40 Strings = OwnedStrings.get();
41}
42
Zachary Turner4e950642017-06-15 23:56:19 +000043void StringsAndChecksumsRef::setChecksums(
44 const DebugChecksumsSubsectionRef &CS) {
45 OwnedChecksums = llvm::make_unique<DebugChecksumsSubsectionRef>();
46 *OwnedChecksums = CS;
47 Checksums = OwnedChecksums.get();
48}
49
Zachary Turnera8cfc292017-06-14 15:59:27 +000050void StringsAndChecksumsRef::initializeChecksums(
51 const DebugSubsectionRecord &FCR) {
52 assert(FCR.kind() == DebugSubsectionKind::FileChecksums);
53 if (Checksums)
54 return;
55
56 OwnedChecksums = llvm::make_unique<DebugChecksumsSubsectionRef>();
57 consumeError(OwnedChecksums->initialize(FCR.getRecordData()));
58 Checksums = OwnedChecksums.get();
59}