]> granicus.if.org Git - clang/commit
Rework our handling of binding a reference to a temporary
authorDouglas Gregor <dgregor@apple.com>
Thu, 20 May 2010 08:36:28 +0000 (08:36 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 20 May 2010 08:36:28 +0000 (08:36 +0000)
commit60dcb8432cff2455488b9226b9cc65b80356146e
tree51be845061c5b07ce0eee89fa1dad8880491f9cc
parent8a2ca744c259882304ebd387fcda30eb68321211
Rework our handling of binding a reference to a temporary
subobject. Previously, we could only properly bind to a base class
subobject while extending the lifetime of the complete object (of a
derived type); for non-static data member subobjects, we could memcpy
(!) the result and bind to that, which is rather broken.

Now, we pull apart the expression that we're binding to, to figure out
which subobject we're accessing, then construct the temporary object
(adding a destruction if needed) and, finally, dig out the subobject
we actually meant to access.

This fixes yet another instance where we were memcpy'ing rather than
doing the right thing. However, note the FIXME in references.cpp:
there's more work to be done for binding to subobjects, since the AST
is incorrectly modeling some member accesses in base classes as
lvalues when they are really rvalues.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104219 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CGExpr.cpp
test/CodeGenCXX/references.cpp