[Codeview] Add a class for LF_UDT_MOD_SRC_LINE.

Differential Revision: http://reviews.llvm.org/D21406

llvm-svn: 272843
This commit is contained in:
Rui Ueyama 2016-06-15 21:25:29 +00:00
parent 63af1aa0c2
commit 5dbea9db10
7 changed files with 130 additions and 70 deletions

View File

@ -767,6 +767,44 @@ private:
uint32_t LineNumber;
};
// LF_UDT_MOD_SRC_LINE
class UdtModSourceLineRecord : public TypeRecord {
public:
UdtModSourceLineRecord(TypeIndex UDT, TypeIndex SourceFile,
uint32_t LineNumber, uint16_t Module)
: TypeRecord(TypeRecordKind::UdtSourceLine), UDT(UDT),
SourceFile(SourceFile), LineNumber(LineNumber), Module(Module) {}
bool remapTypeIndices(ArrayRef<TypeIndex> IndexMap);
static ErrorOr<UdtModSourceLineRecord> deserialize(TypeRecordKind Kind,
ArrayRef<uint8_t> &Data) {
const Layout *L = nullptr;
CV_DESERIALIZE(Data, L);
return UdtModSourceLineRecord(L->UDT, L->SourceFile, L->LineNumber,
L->Module);
}
TypeIndex getUDT() const { return UDT; }
TypeIndex getSourceFile() const { return SourceFile; }
uint32_t getLineNumber() const { return LineNumber; }
uint16_t getModule() const { return Module; }
private:
struct Layout {
TypeIndex UDT; // The user-defined type
TypeIndex SourceFile; // StringID containing the source filename
ulittle32_t LineNumber;
ulittle16_t Module; // Module that contributes this UDT definition
};
TypeIndex UDT;
TypeIndex SourceFile;
uint32_t LineNumber;
uint16_t Module;
};
// LF_BUILDINFO
class BuildInfoRecord : public TypeRecord {
public:

View File

@ -81,6 +81,7 @@ TYPE_RECORD(LF_BUILDINFO, 0x1603, BuildInfo)
TYPE_RECORD_ALIAS(LF_SUBSTR_LIST, 0x1604, StringList, ArgList)
TYPE_RECORD(LF_STRING_ID, 0x1605, StringId)
TYPE_RECORD(LF_UDT_SRC_LINE, 0x1606, UdtSourceLine)
TYPE_RECORD(LF_UDT_MOD_SRC_LINE, 0x1607, UdtModSourceLine)
TYPE_RECORD(LF_METHODLIST, 0x1206, MethodOverloadList)
@ -194,10 +195,6 @@ CV_TYPE(LF_MODIFIER_EX, 0x1518)
CV_TYPE(LF_VECTOR, 0x151b)
CV_TYPE(LF_MATRIX, 0x151c)
// ID leaf records. Subsequent leaf types may be referenced from .debug$S.
CV_TYPE(LF_UDT_MOD_SRC_LINE, 0x1607)
// Numeric leaf types. These are generally contained in other records, and not
// encountered in the main type stream.

View File

@ -51,6 +51,7 @@ public:
TypeIndex writeStringId(const StringIdRecord &Record);
TypeIndex writeVFTable(const VFTableRecord &Record);
TypeIndex writeUdtSourceLine(const UdtSourceLineRecord &Record);
TypeIndex writeUdtModSourceLine(const UdtModSourceLineRecord &Record);
TypeIndex writeFuncId(const FuncIdRecord &Record);
TypeIndex writeMemberFuncId(const MemberFuncIdRecord &Record);
TypeIndex writeBuildInfo(const BuildInfoRecord &Record);

View File

@ -514,6 +514,14 @@ void CVTypeDumperImpl::visitUdtSourceLine(TypeLeafKind Leaf,
W.printNumber("LineNumber", Line.getLineNumber());
}
void CVTypeDumperImpl::visitUdtModSourceLine(TypeLeafKind Leaf,
UdtModSourceLineRecord &Line) {
printTypeIndex("UDT", Line.getUDT());
printTypeIndex("SourceFile", Line.getSourceFile());
W.printNumber("LineNumber", Line.getLineNumber());
W.printNumber("Module", Line.getModule());
}
void CVTypeDumperImpl::visitBuildInfo(TypeLeafKind Leaf,
BuildInfoRecord &Args) {
W.printNumber("NumArgs", static_cast<uint32_t>(Args.getArgs().size()));

View File

@ -491,6 +491,13 @@ bool UdtSourceLineRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
return Success;
}
bool UdtModSourceLineRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
bool Success = true;
Success &= remapIndex(IndexMap, UDT);
Success &= remapIndex(IndexMap, SourceFile);
return Success;
}
bool BuildInfoRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
bool Success = true;
for (TypeIndex &Arg : ArgIndices)

View File

@ -226,7 +226,16 @@ TypeTableBuilder::writeUdtSourceLine(const UdtSourceLineRecord &Record) {
}
TypeIndex
TypeTableBuilder::writeFuncId(const FuncIdRecord &Record) {
TypeTableBuilder::writeUdtModSourceLine(const UdtModSourceLineRecord &Record) {
TypeRecordBuilder Builder(Record.getKind());
Builder.writeTypeIndex(Record.getUDT());
Builder.writeTypeIndex(Record.getSourceFile());
Builder.writeUInt32(Record.getLineNumber());
Builder.writeUInt16(Record.getModule());
return writeRecord(Builder);
}
TypeIndex TypeTableBuilder::writeFuncId(const FuncIdRecord &Record) {
TypeRecordBuilder Builder(Record.getKind());
Builder.writeTypeIndex(Record.getParentScope());
Builder.writeTypeIndex(Record.getFunctionType());

View File

@ -153,72 +153,72 @@
; EMPTY-NEXT: Record count: 15
; EMPTY-NEXT: Records [
; EMPTY-NEXT: {
; EMPTY-NEXT: UnknownLeaf (0x104B) {
; EMPTY-NEXT: UdtModSourceLine (0x104B) {
; EMPTY-NEXT: TypeLeafKind: LF_UDT_MOD_SRC_LINE (0x1607)
; EMPTY-NEXT: UnknownType {
; EMPTY-NEXT: Kind: LF_UDT_MOD_SRC_LINE (0x1607)
; EMPTY-NEXT: Length: 16
; EMPTY-NEXT: }
; EMPTY-NEXT: UDT: __vc_attributes::threadingAttribute (0x100B)
; EMPTY-NEXT: SourceFile: <unknown simple type> (0x1)
; EMPTY-NEXT: LineNumber: 481
; EMPTY-NEXT: Module: 1
; EMPTY-NEXT: }
; EMPTY-NEXT: Bytes (
; EMPTY-NEXT: 0000: 0B100000 01000000 E1010000 0100F2F1 |................|
; EMPTY-NEXT: )
; EMPTY-NEXT: }
; EMPTY-NEXT: {
; EMPTY-NEXT: UnknownLeaf (0x104C) {
; EMPTY-NEXT: UdtModSourceLine (0x104C) {
; EMPTY-NEXT: TypeLeafKind: LF_UDT_MOD_SRC_LINE (0x1607)
; EMPTY-NEXT: UnknownType {
; EMPTY-NEXT: Kind: LF_UDT_MOD_SRC_LINE (0x1607)
; EMPTY-NEXT: Length: 16
; EMPTY-NEXT: }
; EMPTY-NEXT: UDT: __vc_attributes::event_receiverAttribute (0x1017)
; EMPTY-NEXT: SourceFile: <unknown simple type> (0x1)
; EMPTY-NEXT: LineNumber: 194
; EMPTY-NEXT: Module: 1
; EMPTY-NEXT: }
; EMPTY-NEXT: Bytes (
; EMPTY-NEXT: 0000: 17100000 01000000 C2000000 0100F2F1 |................|
; EMPTY-NEXT: )
; EMPTY-NEXT: }
; EMPTY-NEXT: {
; EMPTY-NEXT: UnknownLeaf (0x104D) {
; EMPTY-NEXT: UdtModSourceLine (0x104D) {
; EMPTY-NEXT: TypeLeafKind: LF_UDT_MOD_SRC_LINE (0x1607)
; EMPTY-NEXT: UnknownType {
; EMPTY-NEXT: Kind: LF_UDT_MOD_SRC_LINE (0x1607)
; EMPTY-NEXT: Length: 16
; EMPTY-NEXT: }
; EMPTY-NEXT: UDT: __vc_attributes::aggregatableAttribute (0x1021)
; EMPTY-NEXT: SourceFile: <unknown simple type> (0x1)
; EMPTY-NEXT: LineNumber: 603
; EMPTY-NEXT: Module: 1
; EMPTY-NEXT: }
; EMPTY-NEXT: Bytes (
; EMPTY-NEXT: 0000: 21100000 01000000 5B020000 0100F2F1 |!.......[.......|
; EMPTY-NEXT: )
; EMPTY-NEXT: }
; EMPTY-NEXT: {
; EMPTY-NEXT: UnknownLeaf (0x104E) {
; EMPTY-NEXT: UdtModSourceLine (0x104E) {
; EMPTY-NEXT: TypeLeafKind: LF_UDT_MOD_SRC_LINE (0x1607)
; EMPTY-NEXT: UnknownType {
; EMPTY-NEXT: Kind: LF_UDT_MOD_SRC_LINE (0x1607)
; EMPTY-NEXT: Length: 16
; EMPTY-NEXT: }
; EMPTY-NEXT: UDT: __vc_attributes::event_sourceAttribute (0x102C)
; EMPTY-NEXT: SourceFile: <unknown simple type> (0x1)
; EMPTY-NEXT: LineNumber: 1200
; EMPTY-NEXT: Module: 1
; EMPTY-NEXT: }
; EMPTY-NEXT: Bytes (
; EMPTY-NEXT: 0000: 2C100000 01000000 B0040000 0100F2F1 |,...............|
; EMPTY-NEXT: )
; EMPTY-NEXT: }
; EMPTY-NEXT: {
; EMPTY-NEXT: UnknownLeaf (0x104F) {
; EMPTY-NEXT: UdtModSourceLine (0x104F) {
; EMPTY-NEXT: TypeLeafKind: LF_UDT_MOD_SRC_LINE (0x1607)
; EMPTY-NEXT: UnknownType {
; EMPTY-NEXT: Kind: LF_UDT_MOD_SRC_LINE (0x1607)
; EMPTY-NEXT: Length: 16
; EMPTY-NEXT: }
; EMPTY-NEXT: UDT: __vc_attributes::moduleAttribute (0x103A)
; EMPTY-NEXT: SourceFile: <unknown simple type> (0x1)
; EMPTY-NEXT: LineNumber: 540
; EMPTY-NEXT: Module: 1
; EMPTY-NEXT: }
; EMPTY-NEXT: Bytes (
; EMPTY-NEXT: 0000: 3A100000 01000000 1C020000 0100F2F1 |:...............|
; EMPTY-NEXT: )
; EMPTY-NEXT: }
; EMPTY-NEXT: {
; EMPTY-NEXT: UnknownLeaf (0x1050) {
; EMPTY-NEXT: UdtModSourceLine (0x1050) {
; EMPTY-NEXT: TypeLeafKind: LF_UDT_MOD_SRC_LINE (0x1607)
; EMPTY-NEXT: UnknownType {
; EMPTY-NEXT: Kind: LF_UDT_MOD_SRC_LINE (0x1607)
; EMPTY-NEXT: Length: 16
; EMPTY-NEXT: }
; EMPTY-NEXT: UDT: __vc_attributes::helper_attributes::usageAttribute (0x1042)
; EMPTY-NEXT: SourceFile: <unknown simple type> (0x1)
; EMPTY-NEXT: LineNumber: 108
; EMPTY-NEXT: Module: 1
; EMPTY-NEXT: }
; EMPTY-NEXT: Bytes (
; EMPTY-NEXT: 0000: 42100000 01000000 6C000000 0100F2F1 |B.......l.......|
@ -1003,66 +1003,66 @@
; ALL: Record count: 15
; ALL: Records [
; ALL: {
; ALL: UnknownLeaf (0x104B) {
; ALL: UdtModSourceLine (0x104B) {
; ALL: TypeLeafKind: LF_UDT_MOD_SRC_LINE (0x1607)
; ALL: UnknownType {
; ALL: Kind: LF_UDT_MOD_SRC_LINE (0x1607)
; ALL: Length: 16
; ALL: }
; ALL: UDT: __vc_attributes::threadingAttribute (0x100B)
; ALL: SourceFile: <unknown simple type> (0x1)
; ALL: LineNumber: 481
; ALL: Module: 1
; ALL: }
; ALL: }
; ALL: {
; ALL: UnknownLeaf (0x104C) {
; ALL: UdtModSourceLine (0x104C) {
; ALL: TypeLeafKind: LF_UDT_MOD_SRC_LINE (0x1607)
; ALL: UnknownType {
; ALL: Kind: LF_UDT_MOD_SRC_LINE (0x1607)
; ALL: Length: 16
; ALL: }
; ALL: UDT: __vc_attributes::event_receiverAttribute (0x1017)
; ALL: SourceFile: <unknown simple type> (0x1)
; ALL: LineNumber: 194
; ALL: Module: 1
; ALL: }
; ALL: }
; ALL: {
; ALL: UnknownLeaf (0x104D) {
; ALL: UdtModSourceLine (0x104D) {
; ALL: TypeLeafKind: LF_UDT_MOD_SRC_LINE (0x1607)
; ALL: UnknownType {
; ALL: Kind: LF_UDT_MOD_SRC_LINE (0x1607)
; ALL: Length: 16
; ALL: }
; ALL: UDT: __vc_attributes::aggregatableAttribute (0x1021)
; ALL: SourceFile: <unknown simple type> (0x1)
; ALL: LineNumber: 603
; ALL: Module: 1
; ALL: }
; ALL: }
; ALL: {
; ALL: UnknownLeaf (0x104E) {
; ALL: UdtModSourceLine (0x104E) {
; ALL: TypeLeafKind: LF_UDT_MOD_SRC_LINE (0x1607)
; ALL: UnknownType {
; ALL: Kind: LF_UDT_MOD_SRC_LINE (0x1607)
; ALL: Length: 16
; ALL: }
; ALL: UDT: __vc_attributes::event_sourceAttribute (0x102C)
; ALL: SourceFile: <unknown simple type> (0x1)
; ALL: LineNumber: 1200
; ALL: Module: 1
; ALL: }
; ALL: }
; ALL: {
; ALL: UnknownLeaf (0x104F) {
; ALL: UdtModSourceLine (0x104F) {
; ALL: TypeLeafKind: LF_UDT_MOD_SRC_LINE (0x1607)
; ALL: UnknownType {
; ALL: Kind: LF_UDT_MOD_SRC_LINE (0x1607)
; ALL: Length: 16
; ALL: }
; ALL: UDT: __vc_attributes::moduleAttribute (0x103A)
; ALL: SourceFile: <unknown simple type> (0x1)
; ALL: LineNumber: 540
; ALL: Module: 1
; ALL: }
; ALL: }
; ALL: {
; ALL: UnknownLeaf (0x1050) {
; ALL: UdtModSourceLine (0x1050) {
; ALL: TypeLeafKind: LF_UDT_MOD_SRC_LINE (0x1607)
; ALL: UnknownType {
; ALL: Kind: LF_UDT_MOD_SRC_LINE (0x1607)
; ALL: Length: 16
; ALL: }
; ALL: UDT: __vc_attributes::helper_attributes::usageAttribute (0x1042)
; ALL: SourceFile: <unknown simple type> (0x1)
; ALL: LineNumber: 108
; ALL: Module: 1
; ALL: }
; ALL: }
; ALL: {
; ALL: UnknownLeaf (0x1051) {
; ALL: UdtModSourceLine (0x1051) {
; ALL: TypeLeafKind: LF_UDT_MOD_SRC_LINE (0x1607)
; ALL: UnknownType {
; ALL: Kind: LF_UDT_MOD_SRC_LINE (0x1607)
; ALL: Length: 16
; ALL: }
; ALL: UDT: __vc_attributes::helper_attributes::v1_alttypeAttribute (0x104A)
; ALL: SourceFile: <unknown simple type> (0x1)
; ALL: LineNumber: 96
; ALL: Module: 1
; ALL: }
; ALL: }
; ALL: {