Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions clang/lib/CodeGen/CGExprScalar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2142,9 +2142,9 @@ Value *ScalarExprEmitter::VisitInitListExpr(InitListExpr *E) {
bool Ignore = TestAndClearIgnoreResultAssign();
(void)Ignore;
unsigned NumInitElements = E->getNumInits();
assert(Ignore == false ||
(NumInitElements == 0 && E->getType()->isVoidType()) &&
"init list ignored");
assert((Ignore == false ||
(NumInitElements == 0 && E->getType()->isVoidType())) &&
"init list ignored");
Comment on lines +2145 to +2147
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following alternative is perhaps more clear, and allows to remove the (void)Ignore line from just above.

Suggested change
assert((Ignore == false ||
(NumInitElements == 0 && E->getType()->isVoidType())) &&
"init list ignored");
if (Ignore)
assert(NumInitElements == 0 && E->getType()->isVoidType()
&& "only ignore irrelevant init list");

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That version ends up having a weird dead branch in non-asserts builds, and is problematic as assert is a macro. I don't see the losing the cast as worth the additional risk/breaking up the purpose of the assert here, so I'm going to leave it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, good to me. The extra parentheses solve the GCC warning.


// HLSL initialization lists in the AST are an expansion which can contain
// side-effecting expressions wrapped in opaque value expressions. To properly
Expand Down
Loading