This is an archive of the discontinued LLVM Phabricator instance.

[Clang][AST] Resolve FIXME: Remove ObjCObjectPointer from isSpecifierType
ClosedPublic

Authored by gAlfonso-bit on Sep 20 2021, 6:15 AM.

Details

Summary

There is no reason to have this here, (since all tests pass) and it isn't even a specifier anyway. We can just treat it as a pointer instead.

Diff Detail

Event Timeline

gAlfonso-bit requested review of this revision.Sep 20 2021, 6:15 AM
gAlfonso-bit created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptSep 20 2021, 6:15 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Rebased to upstream

I'm a bit hesitant to trust lack of tests as proof that old FIXMEs can be resolved safely. Can you add some background information about why this was originally a specifier, and why it's safe to fix it now? (If you don't know, I suggest looking through git-blame to figure it out (unless @ahatanak already knows?).)

clang/lib/AST/DeclPrinter.cpp
161–163

Seems unrelated to this commit?

clang/lib/AST/TypePrinter.cpp
313 ↗(On Diff #373955)

Seems unrelated to this commit?

gAlfonso-bit added inline comments.Sep 25 2021, 6:05 AM
clang/lib/AST/DeclPrinter.cpp
161–163

Did it to quiet clang-tidy because I modified this function

gAlfonso-bit marked an inline comment as done.
This comment was removed by gAlfonso-bit.

I'm a bit hesitant to trust lack of tests as proof that old FIXMEs can be resolved safely. Can you add some background information about why this was originally a specifier, and why it's safe to fix it now? (If you don't know, I suggest looking through git-blame to figure it out (unless @ahatanak already knows?).)

This was introduced in 2010, with multiple changes following. The ObjCObjectPointer type was at a time before ObjCObject was defined.

I'm not sure why ObjCObjectPointerType was originally a specifier, but this patch looks safe to me. ObjCObjectPointerType is never passed to TypePrinter::printBefore and QualType GetBaseType, which are the two functions that use isSpecifierType, AFAICT.

John, do you remember why it was necessary to make ObjCObjectPointerType a specifier type?

ObjCObjectPointerType used to have a much weirder representation for the builtin object types like id and Class, and it's possible that this was an artifact of that. Otherwise I'm not sure, sorry.

ahatanak accepted this revision.Oct 7 2021, 10:45 AM

id is a typedef and @class is an ObjCInterface now, so it looks like it's safe to remove ObjCObjectPointer case then.

This revision is now accepted and ready to land.Oct 7 2021, 10:45 AM

Any updates? I do not have commit permissions. @ahatanak

gAlfonso-bit marked an inline comment as done.Oct 20 2021, 7:43 AM

Rebased to main

This comment was removed by gAlfonso-bit.
This revision was automatically updated to reflect the committed changes.