This is an archive of the discontinued LLVM Phabricator instance.

[clang][Headers] Fix unintentional error in D130800
AbandonedPublic

Authored by ddcc on Aug 4 2022, 3:48 PM.

Details

Summary

Undefined macros evaluate to zero, so when checking for a smaller value,
we need to include the case when the macro is undefined.

Diff Detail

Event Timeline

ddcc created this revision.Aug 4 2022, 3:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 4 2022, 3:48 PM
ddcc requested review of this revision.Aug 4 2022, 3:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 4 2022, 3:48 PM
iana accepted this revision.Aug 4 2022, 3:50 PM

That was the only one I saw from D130800, can someone double check me though?

This revision is now accepted and ready to land.Aug 4 2022, 3:50 PM

Undefined macros evaluate to zero, so when checking for a smaller value, we need to include the case when the macro is undefined.

The code being changed already checks defined(__cplusplus) so there no undefined macro value being tested. What's more, if __cplusplus is not defined, we wouldn't even get into this block because we'd have hit line 19 instead. I think the current form is easier to read given the subsequent comment talking about being in C++98 mode (which would be weird to consider for when __cplusplus is not defined), even if the test for defined(__cplusplus) isn't strictly needed.

ddcc added a comment.Aug 5 2022, 10:49 AM

I missed line 19, yeah that makes sense. @iana is that ok with you?

iana added a comment.Aug 5 2022, 10:53 AM

I missed line 19, yeah that makes sense. @iana is that ok with you?

Ah, I didn't see that either. Can we just lose the defined on line 26 then? It's redundant and little confusing.

I missed line 19, yeah that makes sense. @iana is that ok with you?

Ah, I didn't see that either. Can we just lose the defined on line 26 then? It's redundant and little confusing.

I'm fine dropping it (ever so slightly less work for the preprocessor to do in this file), but I don't see what the confusion is with checking whether __cplusplus is defined before testing its value, so I'm also fine with leaving it as-is.

ddcc abandoned this revision.Aug 8 2022, 3:23 PM