blob: 928bf8c94f735b16c71e526ec124da8bd118d681 [file] [log] [blame]
Zachary Turnera8cfc292017-06-14 15:59:27 +00001//===- 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
15using namespace llvm;
16using namespace llvm::codeview;
17
18StringsAndChecksumsRef::StringsAndChecksumsRef() {}
19
20StringsAndChecksumsRef::StringsAndChecksumsRef(
21 const DebugStringTableSubsectionRef &Strings)
22 : Strings(&Strings) {}
23
24StringsAndChecksumsRef::StringsAndChecksumsRef(
25 const DebugStringTableSubsectionRef &Strings,
26 const DebugChecksumsSubsectionRef &Checksums)
27 : Strings(&Strings), Checksums(&Checksums) {}
28
29void 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
Zachary Turner4e950642017-06-15 23:56:19 +000039void StringsAndChecksumsRef::setChecksums(
40 const DebugChecksumsSubsectionRef &CS) {
41 OwnedChecksums = llvm::make_unique<DebugChecksumsSubsectionRef>();
42 *OwnedChecksums = CS;
43 Checksums = OwnedChecksums.get();
44}
45
Zachary Turnera8cfc292017-06-14 15:59:27 +000046void 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}