r183095 - Do not walk through member-accesses on bitfields when looking for the object

David Blaikie dblaikie at gmail.com
Mon Jun 3 09:41:04 PDT 2013


On Mon, Jun 3, 2013 at 12:13 AM, Richard Smith
<richard-llvm at metafoo.co.uk> wrote:
> Author: rsmith
> Date: Mon Jun  3 02:13:35 2013
> New Revision: 183095
>
> URL: http://llvm.org/viewvc/llvm-project?rev=183095&view=rev
> Log:
> Do not walk through member-accesses on bitfields when looking for the object
> which is lifetime-extended by a reference binding. An additional temporary is
> created for such a bitfield access (although we have no explicit AST
> representation for it).
>
> Modified:
>     cfe/trunk/lib/AST/Expr.cpp
>     cfe/trunk/test/CodeGenCXX/temporaries.cpp
>
> Modified: cfe/trunk/lib/AST/Expr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=183095&r1=183094&r2=183095&view=diff
> ==============================================================================
> --- cfe/trunk/lib/AST/Expr.cpp (original)
> +++ cfe/trunk/lib/AST/Expr.cpp Mon Jun  3 02:13:35 2013
> @@ -76,9 +76,11 @@ const Expr *Expr::skipRValueSubobjectAdj
>        if (!ME->isArrow() && ME->getBase()->isRValue()) {
>          assert(ME->getBase()->getType()->isRecordType());
>          if (FieldDecl *Field = dyn_cast<FieldDecl>(ME->getMemberDecl())) {
> -          E = ME->getBase();
> -          Adjustments.push_back(SubobjectAdjustment(Field));
> -          continue;
> +          if (!Field->isBitField()) {
> +            E = ME->getBase();
> +            Adjustments.push_back(SubobjectAdjustment(Field));
> +            continue;
> +          }
>          }
>        }
>      } else if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) {
>
> Modified: cfe/trunk/test/CodeGenCXX/temporaries.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/temporaries.cpp?rev=183095&r1=183094&r2=183095&view=diff
> ==============================================================================
> --- cfe/trunk/test/CodeGenCXX/temporaries.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/temporaries.cpp Mon Jun  3 02:13:35 2013
> @@ -604,3 +604,15 @@ namespace BindToSubobject {
>    // CHECK: store i32* {{.*}}, i32** @_ZN15BindToSubobject1dE, align 8
>    int &&d = (B().a).*h();
>  }
> +
> +namespace Bitfield {
> +  struct S { int a : 5; ~S(); };
> +
> +  // Do not lifetime extend the S() temporary here.
> +Â  // CHECK: alloca

Did some kind of interesting unicode sneak in here?

> +Â  // CHECK: call {{.*}}memset
> +Â  // CHECK: store i32 {{.*}}, i32* @_ZGRN8Bitfield1rE, align 4
> +  // CHECK: call void @_ZN8Bitfield1SD1
> +Â  // CHECK: store i32* @_ZGRN8Bitfield1rE, i32** @_ZN8Bitfield1rE, align 8
> +  int &&r = S().a;
> +}
>
>
> _______________________________________________
> 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