llvm/tools/llvm-pdbutil/MinimalTypeDumper.h
Reid Kleckner 3361fafaf7 [PDB] Finish and simplify TPI hashing
Summary:
This removes the CVTypeVisitor updater and verifier classes. They were
made dead by the minimal type dumping refactoring. Replace them with a
single function that takes a type record and produces a hash. Call this
from the minimal type dumper and compare the hash.

I also noticed that the microsoft-pdb reference repository uses a basic
CRC32 for records that aren't special. We already have an implementation
of that CRC ready to use, because it's used in COFF for ICF.

I'll make LLD call this hashing utility in a follow-up change. We might
also consider using this same hash in type stream merging, so that we
don't have to hash our records twice.

Reviewers: inglorion, ruiu

Subscribers: llvm-commits, hiraditya

Differential Revision: https://reviews.llvm.org/D35515

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308240 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-18 00:33:45 +00:00

64 lines
2.4 KiB
C++

//===- MinimalTypeDumper.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_TOOLS_LLVMPDBUTIL_MINIMAL_TYPE_DUMPER_H
#define LLVM_TOOLS_LLVMPDBUTIL_MINIMAL_TYPE_DUMPER_H
#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
#include "llvm/Support/BinaryStreamArray.h"
namespace llvm {
namespace codeview {
class LazyRandomTypeCollection;
}
namespace pdb {
class LinePrinter;
class MinimalTypeDumpVisitor : public codeview::TypeVisitorCallbacks {
public:
MinimalTypeDumpVisitor(LinePrinter &P, uint32_t Width, bool RecordBytes,
bool Hashes, codeview::LazyRandomTypeCollection &Types,
uint32_t NumHashBuckets,
FixedStreamArray<support::ulittle32_t> HashValues)
: P(P), Width(Width), RecordBytes(RecordBytes), Hashes(Hashes),
Types(Types), NumHashBuckets(NumHashBuckets), HashValues(HashValues) {}
Error visitTypeBegin(codeview::CVType &Record,
codeview::TypeIndex Index) override;
Error visitTypeEnd(codeview::CVType &Record) override;
Error visitMemberBegin(codeview::CVMemberRecord &Record) override;
Error visitMemberEnd(codeview::CVMemberRecord &Record) override;
#define TYPE_RECORD(EnumName, EnumVal, Name) \
Error visitKnownRecord(codeview::CVType &CVR, \
codeview::Name##Record &Record) override;
#define MEMBER_RECORD(EnumName, EnumVal, Name) \
Error visitKnownMember(codeview::CVMemberRecord &CVR, \
codeview::Name##Record &Record) override;
#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
private:
StringRef getTypeName(codeview::TypeIndex TI) const;
LinePrinter &P;
uint32_t Width;
bool RecordBytes = false;
bool Hashes = false;
codeview::LazyRandomTypeCollection &Types;
uint32_t NumHashBuckets;
FixedStreamArray<support::ulittle32_t> HashValues;
};
} // namespace pdb
} // namespace llvm
#endif