This is an archive of the discontinued LLVM Phabricator instance.

Also allow __is_unsigned to be used as an identifier
AbandonedPublic

Authored by sberg on Dec 12 2022, 8:28 AM.

Details

Summary

...similar to 068730992cf08d7d7e82e7bb147d85f429fc3ddd "libstdc++ 4.4 uses __is_signed as an identifier [...]"

Starting with https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=5329e1a8e1480d536ff96283a6556e51112ba470 "libstdc++: Make chrono::hh_mm_ss more compact", libstdc++ 13 trunk used __is_signed as

static constexpr bool __is_unsigned
  = __and_v<is_integral<typename _Duration::rep>,
            is_unsigned<typename _Duration::rep>>;

in libstdc++-v3/include/std/chrono. Even though that got reverted with https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=cb363fd9f19eb791e1ee1eb0d5c61f5fdf21af32 "libstdc++: Change names that clash with Win32 or Clang", it might make sense to treat __is_unsigned the same as __is_signed here (and to also make the workaround hit for constexpr in addition to const).

Diff Detail

Event Timeline

sberg created this revision.Dec 12 2022, 8:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 12 2022, 8:28 AM
sberg requested review of this revision.Dec 12 2022, 8:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 12 2022, 8:28 AM

I'm not opposed to this, but it's unfortunate that this hack is broader than it needs to be because we apply this parsing logic in all circumstances, not just within a system header. However, because we already behave this way for __is_signed, and it seems that parsing hacks do not follow the same pattern as Sema hacks (as in https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaDeclCXX.cpp#L12523 or https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaExceptionSpec.cpp#L44), this seems reasonable to me.

Do you know if folks are hitting problems here in practice, or is this speculative?

The changes should have a release note for the fix.

sberg abandoned this revision.Jan 4 2023, 11:34 PM

Do you know if folks are hitting problems here in practice, or is this speculative?

It had hit me when building LibreOffice against libstdc++ 13 trunk, so I started writing this hack. In parallel, libstdc++ 13 trunk got changed again to not use __is_unsigned as an identifier, so there should be no published releases of libstdc++ where this would be an issue. (And I had finished writing this hack anyway, just in case it might be useful. And then forgot about it... But maybe its best to just abandon it now.)