blob: ccd9aba45eafca36e94aa2f5d769522d2af4d375 [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
39void StringsAndChecksumsRef::initializeChecksums(
40 const DebugSubsectionRecord &FCR) {
41 assert(FCR.kind() == DebugSubsectionKind::FileChecksums);
42 if (Checksums)
43 return;
44
45 OwnedChecksums = llvm::make_unique<DebugChecksumsSubsectionRef>();
46 consumeError(OwnedChecksums->initialize(FCR.getRecordData()));
47 Checksums = OwnedChecksums.get();
48}