[cfe-commits] r72155 - in /cfe/trunk: include/clang/AST/Expr.h lib/CodeGen/CGExpr.cpp test/CodeGenCXX/references.cpp

Anders Carlsson andersca at mac.com
Tue May 19 18:24:23 PDT 2009


Author: andersca
Date: Tue May 19 20:24:22 2009
New Revision: 72155

URL: http://llvm.org/viewvc/llvm-project?rev=72155&view=rev
Log:
Create a temporary if the lvalue is a bitfield. Reported by Eli.

Modified:
    cfe/trunk/include/clang/AST/Expr.h
    cfe/trunk/lib/CodeGen/CGExpr.cpp
    cfe/trunk/test/CodeGenCXX/references.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=72155&r1=72154&r2=72155&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Tue May 19 20:24:22 2009
@@ -182,6 +182,10 @@
   /// declaration of that bit-field.
   FieldDecl *getBitField();
 
+  const FieldDecl *getBitField() const {
+    return const_cast<Expr*>(this)->getBitField();
+  }
+  
   /// isIntegerConstantExpr - Return true if this expression is a valid integer
   /// constant expression, and, if so, return its value in Result.  If not a
   /// valid i-c-e, return false and fill in Loc (if specified) with the location

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=72155&r1=72154&r2=72155&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue May 19 20:24:22 2009
@@ -72,7 +72,7 @@
 
 RValue CodeGenFunction::EmitReferenceBindingToExpr(const Expr* E,
                                                    QualType DestType) {
-  if (E->isLvalue(getContext()) == Expr::LV_Valid) {
+  if (E->isLvalue(getContext()) == Expr::LV_Valid && !E->getBitField()) {
     // Emit the expr as an lvalue.
     LValue LV = EmitLValue(E);
     return RValue::get(LV.getAddress());

Modified: cfe/trunk/test/CodeGenCXX/references.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/references.cpp?rev=72155&r1=72154&r2=72155&view=diff

==============================================================================
--- cfe/trunk/test/CodeGenCXX/references.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/references.cpp Tue May 19 20:24:22 2009
@@ -35,6 +35,9 @@
   int a = 10;
   f(a);
   
+  struct { int bitfield : 3; } s = { 3 };
+  f(s.bitfield)
+  
   f(10);
 }
 





More information about the cfe-commits mailing list