> We had a similar problem with the analyzer, and you can get part of the
> way by overloading on & and &&. The problem with cast is that this is not
> Foo &F = cast<Foo>(getTemporary());
> but this is
I'm just wondering how much of this ^ we really have. If we don't have
much it might be sufficient.
I'm still back at being confused about why we're casting temporaries
though... but I guess that's just More Magic we have in our cast
machinery. Makes me sad.
Actually, any casting involving a temporary is pretty weird:
- downcasting a temporary makes no sense, the dynamic type matches the
Right - but it looks like, somehow, the llvm::cast machinery is
handling this case in some way.
Though it looks like the cast still returns a reference - but I think
it must be a reference to a temporary, so this code (& other uses of
the cast of TypeLocs) is still bogus, I think... but perhaps less
If we could fix this to return by value, then we wouldn't have such a
problem, the original code would've failed to compile (taking a
non-const reference to a temporary) & const refs would at least do
proper lifetime extension.