This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Ignore type sugar in TypeSystemClang::GetPointerType
ClosedPublic

Authored by teemperor on Feb 4 2020, 4:20 AM.

Details

Summary

Currently having a typedef for ObjC types is breaking member access in LLDB:

typedef NSString Str;
NSString *s; s.length; // OK
Str *s; s.length; // Causes: member reference base type 'Str *' (aka 'NSString *') is not a structure or union

This works for NSString as there the type building from NSString -> NSString * will correctly
build a ObjCObjectPointerType (which is necessary to make member access with a dot possible),
but for the typedef the Str -> Str * conversion will produce an incorrect PointerType. The reason
for this is that our check in TypeSystemClang::GetPointerType is not desugaring the base type,
which causes that Str is not recognised as a type to a ObjCInterface as the check only sees the
typedef sugar that was put around it. This causes that we fall back to constructing a PointerType
instead which does not allow member access with the dot operator.

This patch just changes the check to look at the desugared type instead.

Fixes rdar://17525603

Diff Detail

Event Timeline

teemperor created this revision.Feb 4 2020, 4:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 4 2020, 4:20 AM
teemperor edited the summary of this revision. (Show Details)Feb 4 2020, 7:35 AM
mib accepted this revision.Feb 4 2020, 7:43 AM
mib added a subscriber: mib.

LGTM!

This revision is now accepted and ready to land.Feb 4 2020, 7:43 AM
This revision was automatically updated to reflect the committed changes.
davide added a subscriber: davide.Feb 5 2020, 9:29 AM

Good catch.