As discussed in PR38166, we need to be able to distinqush whether the cast
we are visiting is actually a cast, or part of an ExplicitCast.
There are at least four ways to get there:
- Introduce a new CastKind, and use it instead of IntegralCast if we are in ExplicitCast.
Would work, but does not scale - what if we will need more of these cast kinds?
- Introduce a flag in CastExprBits, whether this cast is part of ExplicitCast or not.
Would work, but it isn't immediately clear where it needs to be set.
- Fix ScalarExprEmitter::VisitCastExpr() to visit these NoOp casts.
As pointed out by @rsmith, CodeGenFunction::EmitMaterializeTemporaryExpr calls
skipRValueSubobjectAdjustments, which steps over the CK_NoOp cast`,
which explains why we currently don't visit those.
This is probably impossible, as @efriedma points out, that is intentional as per [class.temporary] in the standard
- And the simplest one, just record which NoOp casts we skip.
It just kinda works as-is afterwards.
But, the approach with a flag is the least intrusive one, and is probably the best one overall.