Index: llvm/lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp =================================================================== --- llvm/lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp +++ llvm/lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp @@ -58,7 +58,7 @@ 8, // LF_UQUADWORD }; - return Sizes[N - LF_NUMERIC]; + return 2 + Sizes[N - LF_NUMERIC]; } static inline uint32_t getCStringLength(ArrayRef Data) { @@ -393,7 +393,7 @@ Refs.push_back({TiRefKind::TypeRef, 0, 1}); // Type break; case SymbolKind::S_REGISTER: - Refs.push_back({TiRefKind::TypeRef, 0, 1}); // Type; + Refs.push_back({TiRefKind::TypeRef, 0, 1}); // Type break; case SymbolKind::S_CONSTANT: Refs.push_back({TiRefKind::TypeRef, 0, 1}); // Type Index: llvm/unittests/DebugInfo/CodeView/TypeIndexDiscoveryTest.cpp =================================================================== --- llvm/unittests/DebugInfo/CodeView/TypeIndexDiscoveryTest.cpp +++ llvm/unittests/DebugInfo/CodeView/TypeIndexDiscoveryTest.cpp @@ -580,3 +580,10 @@ checkTypeReferences(2, TypeIndex(7), TypeIndex(8), TypeIndex(9)); } +// This is a test for getEncodedIntegerLength() +TEST_F(TypeIndexIteratorTest, VariableSizeIntegers) { + BaseClassRecord BaseClass1(MemberAccess::Public, TypeIndex(47), (uint64_t)-1); + BaseClassRecord BaseClass2(MemberAccess::Public, TypeIndex(48), 1); + writeFieldList(BaseClass1, BaseClass2); + checkTypeReferences(0, TypeIndex(47), TypeIndex(48)); +}