This is an archive of the discontinued LLVM Phabricator instance.

[CodeView] Emit the correct TypeIndex for std::nullptr_t
ClosedPublic

Authored by zturner on Oct 31 2018, 4:19 PM.

Details

Summary

The TypeIndex used by cl.exe is 0x103, which indicates a SimpleTypeMode of NearPointer (note the absence of the bitness, normally pointers use a mode of SimpleTypeMode::NearPointer32 or SimpleTypeMode::NearPointer64) and a SimpleTypeKind of void. So this is basically a void*, but without a specified size, which makes sense given how std::nullptr_t is defined.

Anyway, we were actually not emitting *anything* for this. When we encountered std::nullptr_t in a DIType, we would actually just emit a TypeIndex of 0, which is obviously wrong.

The check for this whether we're looking at std::nullptr_t looks hacky, but apparently this is the "official" way to do this in DWARF.

I had to udpate some tests in LLDB since they now start working after this change (meaning the old test with broken output would start failing)

Diff Detail

Repository
rL LLVM

Event Timeline

zturner created this revision.Oct 31 2018, 4:19 PM
rnk accepted this revision.Oct 31 2018, 4:22 PM

Looks good, thanks for the fix.

llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
1518 ↗(On Diff #172043)

I'd reverse this, so we have a special case for nullptr_t, and then the general case of "unspecified type" gives a type index of zero.

This revision is now accepted and ready to land.Oct 31 2018, 4:22 PM
This revision was automatically updated to reflect the committed changes.