really fix 6473 by handling weakref in constant expressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97750 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp
index 3df552d..f0d82a8 100644
--- a/lib/CodeGen/CGExprConstant.cpp
+++ b/lib/CodeGen/CGExprConstant.cpp
@@ -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)) {