This is an archive of the discontinued LLVM Phabricator instance.

Fix __is_pointer builtin type trait to work with Objective-C pointer types.
ClosedPublic

Authored by zoecarver on Apr 5 2020, 7:07 PM.

Details

Summary

5ade17e broke __is_pointer for Objective-C pointer types. This patch fixes the builtin and re-applies the change to type_traits.

Diff Detail

Event Timeline

zoecarver created this revision.Apr 5 2020, 7:07 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptApr 5 2020, 7:07 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
ldionne requested changes to this revision.Apr 6 2020, 6:24 AM

Thanks for looking into this!

clang/test/SemaObjC/type-traits-is-pointer.mm
10 ↗(On Diff #255214)

You can just use static_assert directly here.

libcxx/include/type_traits
901

Doesn't __has_keyword return a number that can be compared against? #if __has_keyword(__is_pointer) > some-number would be better if feasible, because it would handle Clang, AppleClang and any other potential derivative.

This revision now requires changes to proceed.Apr 6 2020, 6:24 AM
zoecarver marked an inline comment as done.Apr 6 2020, 8:38 AM

@ldionne of course!

libcxx/include/type_traits
901

I don't think __has_keyword returns a comparable number. Libc++ defines __has_keyword using __is_identifier [1] and, it seems like all the feature checking macros from clang (including __is_identifier) have bool return types [2]. I can add an AppleClang check too if you want.

[1]:

#define __has_keyword(__x) !(__is_identifier(__x))

[2]: https://clang.llvm.org/docs/LanguageExtensions.html#feature-checking-macros

zoecarver updated this revision to Diff 255361.Apr 6 2020, 8:41 AM

Fix based on review:

  • Use static_assert directly in the test
  • Update run command to work on non-objc platforms (e.g. linux)
zoecarver updated this revision to Diff 255362.Apr 6 2020, 8:41 AM

Diff from master not last commit.

Harbormaster failed remote builds in B51961: Diff 255361!
ldionne accepted this revision.Apr 6 2020, 1:51 PM
ldionne added inline comments.
libcxx/include/type_traits
901

Ah, you're right. There's no version of AppleClang to put here right now, so I'd say status quo is OK. I can add one later.

This revision is now accepted and ready to land.Apr 6 2020, 1:51 PM
ldionne added inline comments.Apr 6 2020, 1:52 PM
clang/test/SemaObjCXX/type-traits-is-pointer.mm
2

Why do you run this through -verify? Can't you just drop that and the // expected-no-diagnostics bit too?

ldionne added inline comments.Apr 7 2020, 5:35 AM
clang/test/SemaObjCXX/type-traits-is-pointer.mm
2

Actually, never mind this. Someone pointed to me offline that using clang-verify has the benefit that no other diagnostics are going to be emitted, which is true. This is fine by me.

zoecarver marked 2 inline comments as done.Apr 8 2020, 9:32 AM
zoecarver added inline comments.
clang/test/SemaObjCXX/type-traits-is-pointer.mm
2

Great, thanks for the review. Most of these tests seem to use -verify so that's what I did.

libcxx/include/type_traits
901

Want me to add a TODO for you?

ldionne added inline comments.Apr 8 2020, 10:12 AM
libcxx/include/type_traits
901

Sure! Thanks!

This revision was automatically updated to reflect the committed changes.