This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Simplify __config a bit
ClosedPublic

Authored by philnik on Jun 12 2022, 2:08 PM.

Details

Reviewers
ldionne
Mordante
var-const
EricWF
Group Reviewers
Restricted Project
Commits
rG929d5de22c49: [libc++] Simplify __config a bit
Summary

Simplify logic in __config by assuming that we are using Clang in C++03 mode. Also, use standardized feature-test macros instead of compiler-specific checks (like __has_feature) in a couple of places.

Diff Detail

Event Timeline

philnik created this revision.Jun 12 2022, 2:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 12 2022, 2:08 PM
philnik requested review of this revision.Jun 12 2022, 2:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 12 2022, 2:08 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript

In general I like the approach. I want to have a closer look when the CI is green.

libcxx/include/__config
211

One of the things bothering about this file is the lack-of overview what indention level parts have.
After processing this patch would it make sense to format this file?
Then all # foo parts have the proper indention.

408–416

Can this be really removed?

428–429

nit: maybe use using instead?

902–903

This looks odd, 199711L refers to C++98. When RTTI is disable is it a "random" value or always 0L?

philnik updated this revision to Diff 436257.Jun 12 2022, 3:16 PM
philnik marked 2 inline comments as done.
  • Address comments
  • Try to fix CI
libcxx/include/__config
211

I'm not sure. clang-format indents everything an unneeded level because we have #ifdef __cplusplus around the whole file. What I've formatted here was done mostly by hand. Although I think it still would be a major improvement over the status quo. I don't think anybody (other than Arthur maybe) would actually care if the default indentation is one to far in. So yeah, it's probably a good idea.

408–416

It looks weird in the diff, but the typedefs are part of the C++03 block above.

902–903

Neither Clang nor GCC define it actually if RTTI is disabled. The || __cpp_rtti < 199711L is more a technically-correct than anything else. I've been bitten by that before with other FTMs.

philnik updated this revision to Diff 436290.Jun 13 2022, 1:29 AM
  • Use attribute
philnik updated this revision to Diff 436302.Jun 13 2022, 2:12 AM
  • Try to fix GCC
ldionne requested changes to this revision.Jun 13 2022, 7:38 AM

Can you please add a description for this change and avoid making formatting changes in the same patch? It seems interesting, but I can't quite figure out what's the essence of the change in its current state.

This revision now requires changes to proceed.Jun 13 2022, 7:38 AM

SGTM, but I will need some time to have a good look at the changes made.

libcxx/include/__config
211

Mainly to make it easier to spot how deeply nested some parts are. Especially in the compiler specific parts.

philnik updated this revision to Diff 437128.Jun 15 2022, 6:15 AM

Rebased and stuff

ldionne accepted this revision.Jun 16 2022, 11:36 AM

I'd like the commit message to explain what's going on here since it's not obvious. From our discussion:

Simplify logic in __config by assuming that we are using Clang in C++03 mode. Also, use standardized feature-test macros instead of compiler-specific checks (like __has_feature) in a couple of places.

LGTM with:

  • A more descriptive commit message
  • CI passing
  • The visibility changes split out.

Thanks a lot, this is actually a really nice refactoring. I am especially looking forward to the split-up patch refactoring visibility attributes.

libcxx/include/__config
535

Can you please split the visibility part of this change into another patch? It's really not related to the rest of the patch.

This revision is now accepted and ready to land.Jun 16 2022, 11:36 AM
philnik updated this revision to Diff 437854.Jun 17 2022, 4:59 AM
  • Remove visibility changes
philnik edited the summary of this revision. (Show Details)Jun 17 2022, 4:59 AM
philnik edited the summary of this revision. (Show Details)
This revision was landed with ongoing or failed builds.Jun 17 2022, 6:54 AM
This revision was automatically updated to reflect the committed changes.