[cfe-commits] r168124 - /cfe/trunk/lib/AST/MicrosoftMangle.cpp

> 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
> valid:
> Foo &F = cast<Foo>(getTemporary());
> but this is
> use(cast<Foo>(getTemporary()))

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
static type

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
dangerously so.

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.