forked from OSchip/llvm-project
parent
2ad0aba610
commit
214567ccfa
|
@ -422,7 +422,6 @@ def : DiagGroup<"arc-abi">;
|
|||
def ARCUnsafeRetainedAssign : DiagGroup<"arc-unsafe-retained-assign">;
|
||||
def ARCRetainCycles : DiagGroup<"arc-retain-cycles">;
|
||||
def ARCNonPodMemAccess : DiagGroup<"arc-non-pod-memaccess">;
|
||||
def ARCBridgeCastRelease : DiagGroup<"arc-bridge-cast-release">;
|
||||
def AutomaticReferenceCounting : DiagGroup<"arc",
|
||||
[ARCUnsafeRetainedAssign,
|
||||
ARCRetainCycles,
|
||||
|
|
|
@ -4459,11 +4459,6 @@ def note_arc_retain_cycle_owner : Note<
|
|||
def warn_arc_object_memaccess : Warning<
|
||||
"%select{destination for|source of}0 this %1 call is a pointer to "
|
||||
"ownership-qualified type %2">, InGroup<ARCNonPodMemAccess>;
|
||||
|
||||
def warn_arc_consumed_object_released : Warning<
|
||||
"__bridge cast of collection literal of type %1 to bridgeable "
|
||||
"type %0 causes early release of the collection">,
|
||||
InGroup<ARCBridgeCastRelease>, DefaultError;
|
||||
|
||||
let CategoryName = "ARC and @properties" in {
|
||||
|
||||
|
|
|
@ -4075,22 +4075,11 @@ ExprResult Sema::BuildObjCBridgedCast(SourceLocation LParenLoc,
|
|||
// Okay: id -> CF
|
||||
CK = CK_BitCast;
|
||||
switch (Kind) {
|
||||
case OBC_Bridge: {
|
||||
const ImplicitCastExpr *implCE = dyn_cast<ImplicitCastExpr>(SubExpr);
|
||||
while (implCE && implCE->getCastKind() == CK_BitCast)
|
||||
implCE = dyn_cast<ImplicitCastExpr>(implCE->getSubExpr());
|
||||
if (implCE && (implCE->getCastKind() == CK_ARCConsumeObject))
|
||||
if (const Expr *LitExp = implCE->getSubExpr())
|
||||
if ((isa<ObjCArrayLiteral>(LitExp) ||
|
||||
isa<ObjCDictionaryLiteral>(LitExp)) &&
|
||||
T->isCARCBridgableType())
|
||||
Diag(BridgeKeywordLoc, diag::warn_arc_consumed_object_released)
|
||||
<< T << implCE->getType();
|
||||
// Reclaiming a value that's going to be __bridge-casted to CF
|
||||
// is very dangerous, so we don't do it.
|
||||
SubExpr = maybeUndoReclaimObject(SubExpr);
|
||||
break;
|
||||
}
|
||||
case OBC_Bridge:
|
||||
// Reclaiming a value that's going to be __bridge-casted to CF
|
||||
// is very dangerous, so we don't do it.
|
||||
SubExpr = maybeUndoReclaimObject(SubExpr);
|
||||
break;
|
||||
|
||||
case OBC_BridgeRetained:
|
||||
// Produce the object before casting it.
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -x objective-c -fobjc-arc -verify -Wno-objc-root-class %s
|
||||
// rdar://18768214
|
||||
|
||||
|
||||
@class NSArray;
|
||||
typedef const struct __attribute__((objc_bridge(NSArray))) __CFArray * CFArrayRef;
|
||||
@class NSString;
|
||||
typedef const void * CFTypeRef;
|
||||
|
||||
typedef const struct __attribute__((objc_bridge(NSString))) __CFString * CFStringRef;
|
||||
|
||||
typedef long NSInteger;
|
||||
typedef unsigned long NSUInteger;
|
||||
|
||||
@interface NSObject {
|
||||
Class isa __attribute__((deprecated));
|
||||
}
|
||||
+ (void)initialize;
|
||||
- (instancetype)init;
|
||||
+ (instancetype)new;
|
||||
+ (instancetype)alloc;
|
||||
- (void)dealloc;
|
||||
@end
|
||||
|
||||
@interface NSArray : NSObject
|
||||
@property (readonly) NSUInteger count;
|
||||
- (id)objectAtIndex:(NSUInteger)index;
|
||||
- (instancetype)init __attribute__((objc_designated_initializer));
|
||||
- (instancetype)initWithObjects:(const id [])objects count:(NSUInteger)cnt __attribute__((objc_designated_initializer));
|
||||
+ (instancetype)array;
|
||||
+ (instancetype)arrayWithObject:(id)anObject;
|
||||
+ (instancetype)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt;
|
||||
+ (instancetype)arrayWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
|
||||
@end
|
||||
|
||||
static CFStringRef _s;
|
||||
|
||||
CFArrayRef _array()
|
||||
{
|
||||
return (__bridge CFArrayRef)@[(__bridge NSString *)_s]; // expected-error {{__bridge cast of collection literal of type 'NSArray *' to bridgeable type 'CFArrayRef' (aka 'const struct __CFArray *') causes early release of the collection}}
|
||||
}
|
Loading…
Reference in New Issue