[llvm-branch-commits] [cfe-branch] r73683 - in /cfe/branches/Apple/Dib: include/clang/AST/Expr.h lib/AST/Expr.cpp lib/CodeGen/CGExpr.cpp test/CodeGenObjC/objc2-strong-cast-2.m
Daniel Dunbar
daniel at zuster.org
Wed Jun 17 21:58:31 PDT 2009
Author: ddunbar
Date: Wed Jun 17 23:58:31 2009
New Revision: 73683
URL: http://llvm.org/viewvc/llvm-project?rev=73683&view=rev
Log:
Merge in 72703 (<rdar://problem/6982258>):
------------------------------------------------------------------------
r72703 | fjahanian | 2009-06-01 14:29:32 -0700 (Mon, 01 Jun 2009) | 3 lines
A corner case of objc2 gc's write-barrier generation
for the Next runtime.
------------------------------------------------------------------------
Modified:
cfe/branches/Apple/Dib/include/clang/AST/Expr.h
cfe/branches/Apple/Dib/lib/AST/Expr.cpp
cfe/branches/Apple/Dib/lib/CodeGen/CGExpr.cpp
cfe/branches/Apple/Dib/test/CodeGenObjC/objc2-strong-cast-2.m
Modified: cfe/branches/Apple/Dib/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/include/clang/AST/Expr.h?rev=73683&r1=73682&r2=73683&view=diff
==============================================================================
--- cfe/branches/Apple/Dib/include/clang/AST/Expr.h (original)
+++ cfe/branches/Apple/Dib/include/clang/AST/Expr.h Wed Jun 17 23:58:31 2009
@@ -250,7 +250,7 @@
/// isOBJCGCCandidate - Return true if this expression may be used in a read/
/// write barrier.
- bool isOBJCGCCandidate() const;
+ bool isOBJCGCCandidate(ASTContext &Ctx) const;
/// IgnoreParens - Ignore parentheses. If this Expr is a ParenExpr, return
/// its subexpression. If that subexpression is also a ParenExpr,
Modified: cfe/branches/Apple/Dib/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/lib/AST/Expr.cpp?rev=73683&r1=73682&r2=73683&view=diff
==============================================================================
--- cfe/branches/Apple/Dib/lib/AST/Expr.cpp (original)
+++ cfe/branches/Apple/Dib/lib/AST/Expr.cpp Wed Jun 17 23:58:31 2009
@@ -924,33 +924,41 @@
/// isOBJCGCCandidate - Check if an expression is objc gc'able.
///
-bool Expr::isOBJCGCCandidate() const {
+bool Expr::isOBJCGCCandidate(ASTContext &Ctx) const {
switch (getStmtClass()) {
default:
return false;
case ObjCIvarRefExprClass:
return true;
case Expr::UnaryOperatorClass:
- return cast<UnaryOperator>(this)->getSubExpr()->isOBJCGCCandidate();
+ return cast<UnaryOperator>(this)->getSubExpr()->isOBJCGCCandidate(Ctx);
case ParenExprClass:
- return cast<ParenExpr>(this)->getSubExpr()->isOBJCGCCandidate();
+ return cast<ParenExpr>(this)->getSubExpr()->isOBJCGCCandidate(Ctx);
case ImplicitCastExprClass:
- return cast<ImplicitCastExpr>(this)->getSubExpr()->isOBJCGCCandidate();
+ return cast<ImplicitCastExpr>(this)->getSubExpr()->isOBJCGCCandidate(Ctx);
case CStyleCastExprClass:
- return cast<CStyleCastExpr>(this)->getSubExpr()->isOBJCGCCandidate();
+ return cast<CStyleCastExpr>(this)->getSubExpr()->isOBJCGCCandidate(Ctx);
case DeclRefExprClass:
case QualifiedDeclRefExprClass: {
const Decl *D = cast<DeclRefExpr>(this)->getDecl();
- if (const VarDecl *VD = dyn_cast<VarDecl>(D))
- return VD->hasGlobalStorage();
+ if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
+ if (VD->hasGlobalStorage())
+ return true;
+ QualType T = VD->getType();
+ // dereferencing to an object pointer is always a gc'able candidate
+ if (T->isPointerType() &&
+ Ctx.isObjCObjectPointerType(T->getAsPointerType()->getPointeeType()))
+ return true;
+
+ }
return false;
}
case MemberExprClass: {
const MemberExpr *M = cast<MemberExpr>(this);
- return M->getBase()->isOBJCGCCandidate();
+ return M->getBase()->isOBJCGCCandidate(Ctx);
}
case ArraySubscriptExprClass:
- return cast<ArraySubscriptExpr>(this)->getBase()->isOBJCGCCandidate();
+ return cast<ArraySubscriptExpr>(this)->getBase()->isOBJCGCCandidate(Ctx);
}
}
Expr* Expr::IgnoreParens() {
Modified: cfe/branches/Apple/Dib/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/lib/CodeGen/CGExpr.cpp?rev=73683&r1=73682&r2=73683&view=diff
==============================================================================
--- cfe/branches/Apple/Dib/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/branches/Apple/Dib/lib/CodeGen/CGExpr.cpp Wed Jun 17 23:58:31 2009
@@ -714,7 +714,7 @@
if (getContext().getLangOptions().ObjC1 &&
getContext().getLangOptions().getGCMode() != LangOptions::NonGC &&
LV.isObjCWeak())
- LValue::SetObjCNonGC(LV, !E->isOBJCGCCandidate());
+ LValue::SetObjCNonGC(LV, !E->isOBJCGCCandidate(getContext()));
return LV;
}
case UnaryOperator::Real:
@@ -849,7 +849,7 @@
getContext().getObjCGCAttrKind(T));
if (getContext().getLangOptions().ObjC1 &&
getContext().getLangOptions().getGCMode() != LangOptions::NonGC)
- LValue::SetObjCNonGC(LV, !E->isOBJCGCCandidate());
+ LValue::SetObjCNonGC(LV, !E->isOBJCGCCandidate(getContext()));
return LV;
}
Modified: cfe/branches/Apple/Dib/test/CodeGenObjC/objc2-strong-cast-2.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/test/CodeGenObjC/objc2-strong-cast-2.m?rev=73683&r1=73682&r2=73683&view=diff
==============================================================================
--- cfe/branches/Apple/Dib/test/CodeGenObjC/objc2-strong-cast-2.m (original)
+++ cfe/branches/Apple/Dib/test/CodeGenObjC/objc2-strong-cast-2.m Wed Jun 17 23:58:31 2009
@@ -1,5 +1,5 @@
// RUN: clang-cc -triple x86_64-darwin-10 -fobjc-gc -emit-llvm -o %t %s &&
-// RUN: grep objc_assign_strongCast %t | count 3 &&
+// RUN: grep objc_assign_strongCast %t | count 4 &&
// RUN: true
@interface A
@@ -19,3 +19,9 @@
((T*) &g0)->a[0] = x;
}
+void f2(unsigned idx)
+{
+ id *keys;
+ keys[idx] = 0;
+}
+
More information about the llvm-branch-commits
mailing list