This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Remove usage of `_LIBCPP_DEBUG` in `__comp_ref_type` and replace with `_LIBCPP_DEBUG_LEVEL`
ClosedPublic

Authored by rupprecht on Feb 3 2022, 3:08 PM.

Details

Summary

In libc++, checking specific _LIBCPP_DEBUG_LEVEL levels is used everywhere except in comp_ref_type.h. _LIBCPP_DEBUG is meant as a user-facing option, and internally libc++ should be checking the value of _LIBCPP_DEBUG_LEVEL.

The definition of std::__debug_less doesn't need to be hidden behind the macro, we can unconditionally expose it. It will be unused by __comp_ref_type unless debug mode is enabled.

This was suggested in D118940.

Diff Detail

Event Timeline

rupprecht requested review of this revision.Feb 3 2022, 3:08 PM
rupprecht created this revision.
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a reviewer: Restricted Project. · View Herald Transcript
philnik accepted this revision as: philnik.Feb 3 2022, 3:13 PM
philnik added a subscriber: philnik.

LGTM if CI is green. I'd still like to see _LIBCPP_HIDE_FROM_ABI, but I'm not making you replace it. We replace it incrementally because it would be a huge change.

Quuxplusone added reviewers: ldionne, Mordante.

This looks fine to me, but I would feel better if @ldionne also looked at it.

ldionne accepted this revision.Feb 4 2022, 1:24 PM

This looks correct to me, but thanks for waiting. The debug mode is sometimes tricky, but in this case this really looks like an oversight. Basically, _LIBCPP_DEBUG is the user-facing option, and the library should use _LIBCPP_DEBUG_LEVEL internally.

However, the commit summary says "Remove _LIBCPP_DEBUG and replace with _LIBCPP_DEBUG_LEVEL", which is misleading. I thought you were removing _LIBCPP_DEBUG entirely at first. I think this would be better: "Remove usage of _LIBCPP_DEBUG in __comp_ref_type" or something along those lines.

This revision is now accepted and ready to land.Feb 4 2022, 1:24 PM
rupprecht retitled this revision from [libc++] Remove `_LIBCPP_DEBUG` and replace with `_LIBCPP_DEBUG_LEVEL` to [libc++] Remove usage of `_LIBCPP_DEBUG` in `__comp_ref_type` and replace with `_LIBCPP_DEBUG_LEVEL`.Feb 10 2022, 9:01 AM
rupprecht edited the summary of this revision. (Show Details)

This looks correct to me, but thanks for waiting. The debug mode is sometimes tricky, but in this case this really looks like an oversight. Basically, _LIBCPP_DEBUG is the user-facing option, and the library should use _LIBCPP_DEBUG_LEVEL internally.

However, the commit summary says "Remove _LIBCPP_DEBUG and replace with _LIBCPP_DEBUG_LEVEL", which is misleading. I thought you were removing _LIBCPP_DEBUG entirely at first. I think this would be better: "Remove usage of _LIBCPP_DEBUG in __comp_ref_type" or something along those lines.

Done, and added your elaboration on the user-facing vs internal difference, thanks for that clarification.

This revision was landed with ongoing or failed builds.Feb 10 2022, 9:04 AM
This revision was automatically updated to reflect the committed changes.