[cfe-commits] r117146 - in /cfe/trunk: lib/CodeGen/CGExprAgg.cpp lib/CodeGen/CGExprCXX.cpp lib/CodeGen/CGValue.h test/CodeGenCXX/stmtexpr-copy-init.cpp
Eli Friedman
eli.friedman at gmail.com
Fri Oct 22 14:36:21 PDT 2010
On Fri, Oct 22, 2010 at 2:01 PM, Fariborz Jahanian <fjahanian at apple.com> wrote:
> Author: fjahanian
> Date: Fri Oct 22 16:01:02 2010
> New Revision: 117146
>
> URL: http://llvm.org/viewvc/llvm-project?rev=117146&view=rev
> Log:
> Patch fixes miscompile with non-trivial copy constructors and
> statement expressions, //rdar: //8540501
>
> Added:
> cfe/trunk/test/CodeGenCXX/stmtexpr-copy-init.cpp
> Modified:
> cfe/trunk/lib/CodeGen/CGExprAgg.cpp
> cfe/trunk/lib/CodeGen/CGExprCXX.cpp
> cfe/trunk/lib/CodeGen/CGValue.h
>
> Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=117146&r1=117145&r2=117146&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Fri Oct 22 16:01:02 2010
> @@ -147,6 +147,23 @@
> /// represents a value lvalue, this method emits the address of the lvalue,
> /// then loads the result into DestPtr.
> void AggExprEmitter::EmitAggLoadOfLValue(const Expr *E) {
> + if (CGF.getContext().getLangOptions().CPlusPlus) {
> + if (const CXXConstructExpr *CE = Dest.getCtorExpr()) {
> + // Perform copy initialization of Src into Dest.
> + const CXXConstructorDecl *CD = CE->getConstructor();
> + CXXCtorType Type =
> + (CE->getConstructionKind() == CXXConstructExpr::CK_Complete)
> + ? Ctor_Complete : Ctor_Base;
> + bool ForVirtualBase =
> + CE->getConstructionKind() == CXXConstructExpr::CK_VirtualBase;
> + // Call the constructor.
> + const Stmt * S = dyn_cast<Stmt>(E);
> + clang::ConstExprIterator BegExp(&S);
> + CGF.EmitCXXConstructorCall(CD, Type, ForVirtualBase, Dest.getAddr(),
> + BegExp, (BegExp+1));
There's no way this is possibly correct; please revert and start a
discussion of the issue on cfe-dev.
-Eli
More information about the cfe-commits
mailing list