Page MenuHomePhabricator

Mark if a null statement is the result of constexpr folding
Needs ReviewPublic

Authored by xazax.hun on Apr 29 2018, 5:01 AM.

Details

Reviewers
aaron.ballman
Summary

I did not add tests yet because first I wanted to be sure whether this approach is OK.

Diff Detail

Event Timeline

xazax.hun created this revision.Apr 29 2018, 5:01 AM
rsmith added a subscriber: rsmith.Apr 29 2018, 12:44 PM

Can you say something about why you want to track this?

Perhaps we should just use a null pointer for the not-instantiated arm of an if constexpr instead, rather than tracking a flag on an empty statement that is meaningless for real empty statements.

Can you say something about why you want to track this?

The original motivation was to fix this false positive in clang tidy: https://reviews.llvm.org/D46027

Perhaps we should just use a null pointer for the not-instantiated arm of an if constexpr instead, rather than tracking a flag on an empty statement that is meaningless for real empty statements.

I will look into that, thanks. I wonder if any of the code assumes that the than branch always present.

Perhaps we should just use a null pointer for the not-instantiated arm of an if constexpr instead, rather than tracking a flag on an empty statement that is meaningless for real empty statements.

I will look into that, thanks. I wonder if any of the code assumes that the than branch always present.

I expect some code does. But this is fundamentally a special property of an if constexpr statement, not of an empty statement, so I think it makes most sense that whatever special handling we choose to use for this should live in the IfStmt.

Just a note for anyone willing to pick this up, PR32203 is also related.

Herald added a project: Restricted Project. · View Herald TranscriptNov 27 2019, 11:11 AM

Just a note for anyone willing to pick this up, PR32203 is also related.

Further note: the right approach here would likely be to add a DiscardedStmt class deriving from Stmt that represents a discarded arm of an if constexpr, rather than modeling this as a NullStmt.