-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
src: use struct as arguments to node::Assert #25869
Conversation
@@ -120,9 +126,10 @@ void DumpBacktrace(FILE* fp); | |||
#define CHECK(expr) \ | |||
do { \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're here, would you consider de-crufting this? i.e.:
if (!(expr)) { \
node::Assert({ __FILE__, __LINE__, #expr, PRETTY_FUNCTION_NAME }); \
} \
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@refack At least locally (gcc-7 on Ubuntu 18.04), that would undo the purpose of this (what the comment is referring to): It would put the object construction in-line into the code instead of ending up as a simple pointer load from the read-only data section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So how about:
if (!(expr)) { \
static constexpr args{ __FILE__, __LINE__, #expr, PRETTY_FUNCTION_NAME } \
node::Assert(args); \
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@refack You are talking about const
→ constexpr
, right? That has the same result for me, and I don’t see it as being clearer about the intention here (having an explicit, hardcoded object in the read-only data section).
I’ll make the comment more explicit about what the idea here is.
This just makes the code a bit more obvious (subjectively).
Landed in 30545a5 |
This just makes the code a bit more obvious (subjectively). PR-URL: #25869 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This just makes the code a bit more obvious (subjectively). PR-URL: #25869 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This just makes the code a bit more obvious (subjectively).
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes