Files
archived-llvm/include/llvm/DebugInfo/CodeView/CVRecord.h
Zachary Turner 5e117855c3 [msf] Resubmit "Rename Msf -> MSF".
Previously this change was submitted from a Windows machine, so
changes made to the case of filenames and directory names did
not survive the commit, and as a result the CMake source file
names and the on-disk file names did not match on case-sensitive
file systems.

I'm resubmitting this patch from a Linux system, which hopefully
allows the case changes to make it through unfettered.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277213 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-29 20:56:36 +00:00

62 lines
1.8 KiB
C++

//===- RecordIterator.h -----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_DEBUGINFO_CODEVIEW_RECORDITERATOR_H
#define LLVM_DEBUGINFO_CODEVIEW_RECORDITERATOR_H
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/DebugInfo/CodeView/CodeViewError.h"
#include "llvm/DebugInfo/CodeView/RecordSerialization.h"
#include "llvm/DebugInfo/MSF/StreamReader.h"
#include "llvm/DebugInfo/MSF/StreamRef.h"
#include "llvm/Support/Endian.h"
namespace llvm {
namespace codeview {
template <typename Kind> struct CVRecord {
uint32_t Length;
Kind Type;
ArrayRef<uint8_t> Data;
ArrayRef<uint8_t> RawData;
};
}
namespace msf {
template <typename Kind>
struct VarStreamArrayExtractor<codeview::CVRecord<Kind>> {
Error operator()(ReadableStreamRef Stream, uint32_t &Len,
codeview::CVRecord<Kind> &Item) const {
using namespace codeview;
const RecordPrefix *Prefix = nullptr;
StreamReader Reader(Stream);
uint32_t Offset = Reader.getOffset();
if (auto EC = Reader.readObject(Prefix))
return EC;
Item.Length = Prefix->RecordLen;
if (Item.Length < 2)
return make_error<CodeViewError>(cv_error_code::corrupt_record);
Item.Type = static_cast<Kind>(uint16_t(Prefix->RecordKind));
Reader.setOffset(Offset);
if (auto EC =
Reader.readBytes(Item.RawData, Item.Length + sizeof(uint16_t)))
return EC;
Item.Data = Item.RawData.slice(sizeof(RecordPrefix));
Len = Prefix->RecordLen + 2;
return Error::success();
}
};
}
}
#endif