-
Notifications
You must be signed in to change notification settings - Fork 10.5k
RequirementMachine: Convert to new assertions #74631
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
Conversation
d558624
to
db7fa8c
Compare
21ea00b
to
fcc0702
Compare
@@ -43,7 +43,7 @@ | |||
|
|||
#define ASSERT(expr) \ | |||
do { \ | |||
if (ASSERT_UNLIKELY(!expr)) { \ | |||
if (ASSERT_UNLIKELY(!(expr))) { \ |
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.
Ouch. Good catch!
ASSERT(!props->isConcreteType() && | ||
"Concrete types do not have conformance access paths"); | ||
auto conformsTo = props->getConformsTo(); | ||
CONDITIONAL_ASSERT(std::find(conformsTo.begin(), conformsTo.end(), protocol) && |
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.
Not much point to having CONDITIONAL_ASSERT
inside a CONDITIONAL_ASSERT_enabled
block.
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.
Ah, good catch.
auto prefixBegin = lookupTerm.begin(); | ||
auto prefixEnd = lookupTerm.end() - Key.size(); | ||
assert(std::equal(prefixEnd, lookupTerm.end(), Key.begin()) && | ||
"This is not the bag you're looking for"); | ||
DEBUG_ASSERT(std::equal(prefixEnd, lookupTerm.end(), Key.begin()) && |
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.
Why DEBUG_ASSERT
here? (Genuinely curious.)
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.
It seemed that in a few places the asserts are extremely defensive because the caller establishes the condition immediately... but maybe that line of reasoning defeats the purpose of asserts!
I also used DEBUG_ASSERT in a few 'inner loops'. I was going to profile this patch anyway so I can play around with things a bit to see where we stand.
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.
Thanks for that clarification. It helps to hear people talk about how they think of these things.
I'm curious about the use of |
ae63615
to
4795a13
Compare
af03db2
to
273c4b2
Compare
@swift-ci Please smoke test |
No description provided.