This is an archive of the discontinued LLVM Phabricator instance.

[clang][Interp] Fix tests for ignored expressions
ClosedPublic

Authored by tbaeder on May 5 2023, 8:12 AM.

Details

Summary
We didn't call the function explicitly in a static_assert() statement
and the checkPotentialConstantExpression() invocation quietly aborted
early because of the missing initializer for A::a.

Fix this by calling ignoredExprs() explicitly.

Diff Detail

Event Timeline

tbaeder created this revision.May 5 2023, 8:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 5 2023, 8:12 AM
tbaeder requested review of this revision.May 5 2023, 8:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 5 2023, 8:12 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
tbaeder updated this revision to Diff 520352.May 8 2023, 6:40 AM

@aaron.ballman This is where the sizeof/alignof tests were actually broken.

aaron.ballman added inline comments.May 8 2023, 9:17 AM
clang/lib/AST/Interp/ByteCodeExprGen.cpp
533–534

For my own understanding -- why do we not need to call discard() on the operand expression?

clang/test/AST/Interp/literals.cpp
204–205
tbaeder added inline comments.May 8 2023, 9:22 AM
clang/lib/AST/Interp/ByteCodeExprGen.cpp
533–534

Is it ever legal to have an argument expr with side effects (in cases the constant expression interpreter needs to handle)? That's really the only reason I did it this way.

aaron.ballman accepted this revision.May 8 2023, 9:25 AM

LGTM

clang/lib/AST/Interp/ByteCodeExprGen.cpp
533–534

Ah, I see! No, I don't think it's possible to have an expression argument with side effects that's valid in a constant expression for these operators.

This revision is now accepted and ready to land.May 8 2023, 9:25 AM
This revision was landed with ongoing or failed builds.Aug 1 2023, 5:59 AM
This revision was automatically updated to reflect the committed changes.