[cfe-commits] r138627 - in /cfe/trunk: lib/CodeGen/CGExprAgg.cpp lib/CodeGen/CGExprCXX.cpp lib/CodeGen/CGValue.h test/CodeGenCXX/conditional-expr-lvalue.cpp
Nico Weber
thakis at chromium.org
Fri Aug 26 00:47:31 PDT 2011
Thanks!
On Fri, Aug 26, 2011 at 7:31 AM, John McCall <rjmccall at apple.com> wrote:
> Author: rjmccall
> Date: Fri Aug 26 02:31:35 2011
> New Revision: 138627
>
> URL: http://llvm.org/viewvc/llvm-project?rev=138627&view=rev
> Log:
> Since the 'is aliased' bit is critical for correctness in C++, it
> really shouldn't be optional. Fix the remaining place where a
> temporary was being passed as potentially-aliased memory.
>
> Fixes PR10756.
>
>
> Modified:
> cfe/trunk/lib/CodeGen/CGExprAgg.cpp
> cfe/trunk/lib/CodeGen/CGExprCXX.cpp
> cfe/trunk/lib/CodeGen/CGValue.h
> cfe/trunk/test/CodeGenCXX/conditional-expr-lvalue.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=138627&r1=138626&r2=138627&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Fri Aug 26 02:31:35 2011
> @@ -444,7 +444,8 @@
> LValue RHS = CGF.EmitLValue(E->getRHS());
> LValue LHS = CGF.EmitLValue(E->getLHS());
> Dest = AggValueSlot::forLValue(LHS, AggValueSlot::IsDestructed,
> - needsGC(E->getLHS()->getType()));
> + needsGC(E->getLHS()->getType()),
> + AggValueSlot::IsAliased);
> EmitFinalDestCopy(E, RHS, true);
> return;
> }
> @@ -469,7 +470,8 @@
> // Codegen the RHS so that it stores directly into the LHS.
> AggValueSlot LHSSlot =
> AggValueSlot::forLValue(LHS, AggValueSlot::IsDestructed,
> - needsGC(E->getLHS()->getType()));
> + needsGC(E->getLHS()->getType()),
> + AggValueSlot::IsAliased);
> CGF.EmitAggExpr(E->getRHS(), LHSSlot, false);
> EmitFinalDestCopy(E, LHS, true);
> }
> @@ -1052,7 +1054,8 @@
> llvm::Value *Temp = CreateMemTemp(E->getType());
> LValue LV = MakeAddrLValue(Temp, E->getType());
> EmitAggExpr(E, AggValueSlot::forLValue(LV, AggValueSlot::IsNotDestructed,
> - AggValueSlot::DoesNotNeedGCBarriers));
> + AggValueSlot::DoesNotNeedGCBarriers,
> + AggValueSlot::IsNotAliased));
> return LV;
> }
>
>
> Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=138627&r1=138626&r2=138627&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Fri Aug 26 02:31:35 2011
> @@ -705,7 +705,8 @@
> AggValueSlot Slot
> = AggValueSlot::forAddr(NewPtr, AllocType.getQualifiers(),
> AggValueSlot::IsDestructed,
> - AggValueSlot::DoesNotNeedGCBarriers);
> + AggValueSlot::DoesNotNeedGCBarriers,
> + AggValueSlot::IsNotAliased);
> CGF.EmitAggExpr(Init, Slot);
> }
> }
>
> Modified: cfe/trunk/lib/CodeGen/CGValue.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGValue.h?rev=138627&r1=138626&r2=138627&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGValue.h (original)
> +++ cfe/trunk/lib/CodeGen/CGValue.h Fri Aug 26 02:31:35 2011
> @@ -383,7 +383,7 @@
> static AggValueSlot forAddr(llvm::Value *addr, Qualifiers quals,
> IsDestructed_t isDestructed,
> NeedsGCBarriers_t needsGC,
> - IsAliased_t isAliased = IsAliased,
> + IsAliased_t isAliased,
> IsZeroed_t isZeroed = IsNotZeroed) {
> AggValueSlot AV;
> AV.Addr = addr;
> @@ -397,7 +397,7 @@
>
> static AggValueSlot forLValue(LValue LV, IsDestructed_t isDestructed,
> NeedsGCBarriers_t needsGC,
> - IsAliased_t isAliased = IsAliased,
> + IsAliased_t isAliased,
> IsZeroed_t isZeroed = IsNotZeroed) {
> return forAddr(LV.getAddress(), LV.getQuals(),
> isDestructed, needsGC, isAliased, isZeroed);
>
> Modified: cfe/trunk/test/CodeGenCXX/conditional-expr-lvalue.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/conditional-expr-lvalue.cpp?rev=138627&r1=138626&r2=138627&view=diff
> ==============================================================================
> --- cfe/trunk/test/CodeGenCXX/conditional-expr-lvalue.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/conditional-expr-lvalue.cpp Fri Aug 26 02:31:35 2011
> @@ -5,3 +5,16 @@
>
> (flag ? a : b) = 3;
> }
> +
> +// PR10756
> +namespace test0 {
> + struct A {
> + A(const A &);
> + A &operator=(const A &);
> + A sub() const;
> + void foo() const;
> + };
> + void foo(bool cond, const A &a) {
> + (cond ? a : a.sub()).foo();
> + }
> +}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
More information about the cfe-commits
mailing list