[cfe-commits] r97750 - in /cfe/trunk: lib/CodeGen/CGExprConstant.cpp test/CodeGen/attr-weakref.c

Rafael Espindola rafael.espindola at gmail.com
Thu Mar 4 13:26:03 PST 2010


Author: rafael
Date: Thu Mar  4 15:26:03 2010
New Revision: 97750

URL: http://llvm.org/viewvc/llvm-project?rev=97750&view=rev
Log:
really fix 6473 by handling weakref in constant expressions.

Modified:
    cfe/trunk/lib/CodeGen/CGExprConstant.cpp
    cfe/trunk/test/CodeGen/attr-weakref.c

Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=97750&r1=97749&r2=97750&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Thu Mar  4 15:26:03 2010
@@ -761,7 +761,9 @@
       return C;
     }
     case Expr::DeclRefExprClass: {
-      NamedDecl *Decl = cast<DeclRefExpr>(E)->getDecl();
+      ValueDecl *Decl = cast<DeclRefExpr>(E)->getDecl();
+      if (Decl->hasAttr<WeakRefAttr>())
+	return CGM.GetWeakRefReference(Decl);
       if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(Decl))
         return CGM.GetAddrOfFunction(FD);
       if (const VarDecl* VD = dyn_cast<VarDecl>(Decl)) {

Modified: cfe/trunk/test/CodeGen/attr-weakref.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-weakref.c?rev=97750&r1=97749&r2=97750&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/attr-weakref.c (original)
+++ cfe/trunk/test/CodeGen/attr-weakref.c Thu Mar  4 15:26:03 2010
@@ -52,3 +52,11 @@
 void test6_foo(void) {
   test6_f();
 }
+
+// CHECK: declare extern_weak void @test7_f()
+void test7_f(void);
+static void test7_g(void) __attribute__((weakref("test7_f")));
+static void *const test7_zed = (void *) &test7_g;
+void* test7_h(void) {
+  return test7_zed;
+}





More information about the cfe-commits mailing list