From 9ad94aa280619feaed083fd35f9a50c7e076a7b0 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Tue, 28 Oct 2014 18:28:16 +0000 Subject: [PATCH] Objective-C. revert patch for rdar://17554063. llvm-svn: 220812 --- clang/include/clang/AST/ExprObjC.h | 18 ------ clang/include/clang/AST/NSAPI.h | 5 +- clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 - clang/include/clang/Sema/Sema.h | 12 ---- clang/lib/AST/Expr.cpp | 15 ++--- clang/lib/AST/NSAPI.cpp | 17 ----- clang/lib/CodeGen/CGObjC.cpp | 18 +----- clang/lib/CodeGen/CodeGenFunction.h | 3 +- clang/lib/Sema/Sema.cpp | 4 -- clang/lib/Sema/SemaExprObjC.cpp | 75 ++++------------------- clang/lib/Serialization/ASTReaderStmt.cpp | 2 - clang/lib/Serialization/ASTWriterStmt.cpp | 2 - clang/test/CodeGenObjC/Inputs/literal-support.h | 10 +-- clang/test/CodeGenObjC/arc-literals.m | 34 +++++----- clang/test/CodeGenObjCXX/Inputs/literal-support.h | 9 +-- clang/test/CodeGenObjCXX/literals.mm | 13 +--- clang/test/SemaObjC/arc.m | 18 ++---- clang/test/SemaObjC/objc-literal-comparison.m | 5 -- clang/tools/libclang/IndexBody.cpp | 6 -- 19 files changed, 49 insertions(+), 219 deletions(-) diff --git a/clang/include/clang/AST/ExprObjC.h b/clang/include/clang/AST/ExprObjC.h index 3145549..817c0cc 100644 --- a/clang/include/clang/AST/ExprObjC.h +++ b/clang/include/clang/AST/ExprObjC.h @@ -134,13 +134,9 @@ class ObjCArrayLiteral : public Expr { unsigned NumElements; SourceRange Range; ObjCMethodDecl *ArrayWithObjectsMethod; - /// \brief in arc mode, this field holds array allocation method declaration. - /// In MRR mode, it is null - ObjCMethodDecl *ArrayAllocMethod; ObjCArrayLiteral(ArrayRef Elements, QualType T, ObjCMethodDecl * Method, - ObjCMethodDecl *allocMethod, SourceRange SR); explicit ObjCArrayLiteral(EmptyShell Empty, unsigned NumElements) @@ -150,7 +146,6 @@ public: static ObjCArrayLiteral *Create(const ASTContext &C, ArrayRef Elements, QualType T, ObjCMethodDecl * Method, - ObjCMethodDecl *allocMethod, SourceRange SR); static ObjCArrayLiteral *CreateEmpty(const ASTContext &C, @@ -189,10 +184,6 @@ public: return ArrayWithObjectsMethod; } - ObjCMethodDecl *getArrayAllocMethod() const { - return ArrayAllocMethod; - } - // Iterators child_range children() { return child_range((Stmt **)getElements(), @@ -265,15 +256,10 @@ class ObjCDictionaryLiteral : public Expr { SourceRange Range; ObjCMethodDecl *DictWithObjectsMethod; - - /// \brief for arc-specific dictionary literals, this field is used to store - /// NSDictionary allocation method declaration. It is null for MRR mode. - ObjCMethodDecl *DictAllocMethod; ObjCDictionaryLiteral(ArrayRef VK, bool HasPackExpansions, QualType T, ObjCMethodDecl *method, - ObjCMethodDecl *allocMethod, SourceRange SR); explicit ObjCDictionaryLiteral(EmptyShell Empty, unsigned NumElements, @@ -308,7 +294,6 @@ public: ArrayRef VK, bool HasPackExpansions, QualType T, ObjCMethodDecl *method, - ObjCMethodDecl *allocMethod, SourceRange SR); static ObjCDictionaryLiteral *CreateEmpty(const ASTContext &C, @@ -335,9 +320,6 @@ public: ObjCMethodDecl *getDictWithObjectsMethod() const { return DictWithObjectsMethod; } - ObjCMethodDecl *getDictAllocMethod() const - { return DictAllocMethod; } - SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); } SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); } SourceRange getSourceRange() const LLVM_READONLY { return Range; } diff --git a/clang/include/clang/AST/NSAPI.h b/clang/include/clang/AST/NSAPI.h index 764bf19..d818a03 100644 --- a/clang/include/clang/AST/NSAPI.h +++ b/clang/include/clang/AST/NSAPI.h @@ -77,10 +77,9 @@ public: NSArr_initWithArray, NSArr_initWithObjects, NSArr_objectAtIndex, - NSMutableArr_replaceObjectAtIndex, - NSArr_initWithObjectsCount + NSMutableArr_replaceObjectAtIndex }; - static const unsigned NumNSArrayMethods = 10; + static const unsigned NumNSArrayMethods = 9; /// \brief The Objective-C NSArray selectors. Selector getNSArraySelector(NSArrayMethodKind MK) const; diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index d05f94b..da6d5977 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -2046,8 +2046,6 @@ def err_undeclared_nsarray : Error< def err_undeclared_nsdictionary : Error< "NSDictionary must be available to use Objective-C dictionary " "literals">; -def err_undeclared_alloc : Error< - "alloc must be available to use Objective-C literals">; def err_undeclared_boxing_method : Error< "declaration of %0 is missing in %1 class">; def err_objc_literal_method_sig : Error< diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 549cf14..2ecaf53 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -681,24 +681,12 @@ public: /// \brief The declaration of the arrayWithObjects:count: method. ObjCMethodDecl *ArrayWithObjectsMethod; - - /// \brief The declaration of the initWithObjects:count: method. - ObjCMethodDecl *InitArrayWithObjectsMethod; /// \brief The declaration of the Objective-C NSDictionary class. ObjCInterfaceDecl *NSDictionaryDecl; /// \brief The declaration of the dictionaryWithObjects:forKeys:count: method. ObjCMethodDecl *DictionaryWithObjectsMethod; - - /// \brief The declaration of the initWithObjects:forKeys:count: method. - ObjCMethodDecl *InitDictionaryWithObjectsMethod; - - /// \brief The declaration for + (id) alloc method used in [NSArray alloc] - ObjCMethodDecl *ArrayAllocObjectsMethod; - - /// \brief The declaration for + (id) alloc method used in [NSDictionary alloc] - ObjCMethodDecl *DictAllocObjectsMethod; /// \brief id type. QualType QIDNSCopying; diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index ec679f0..a76d505 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -4082,12 +4082,10 @@ Stmt::child_range ObjCMessageExpr::children() { ObjCArrayLiteral::ObjCArrayLiteral(ArrayRef Elements, QualType T, ObjCMethodDecl *Method, - ObjCMethodDecl *AllocMethod, SourceRange SR) : Expr(ObjCArrayLiteralClass, T, VK_RValue, OK_Ordinary, false, false, false, false), - NumElements(Elements.size()), Range(SR), ArrayWithObjectsMethod(Method), - ArrayAllocMethod(AllocMethod) + NumElements(Elements.size()), Range(SR), ArrayWithObjectsMethod(Method) { Expr **SaveElements = getElements(); for (unsigned I = 0, N = Elements.size(); I != N; ++I) { @@ -4105,11 +4103,10 @@ ObjCArrayLiteral::ObjCArrayLiteral(ArrayRef Elements, ObjCArrayLiteral *ObjCArrayLiteral::Create(const ASTContext &C, ArrayRef Elements, QualType T, ObjCMethodDecl * Method, - ObjCMethodDecl *allocMethod, SourceRange SR) { void *Mem = C.Allocate(sizeof(ObjCArrayLiteral) + Elements.size() * sizeof(Expr *)); - return new (Mem) ObjCArrayLiteral(Elements, T, Method, allocMethod, SR); + return new (Mem) ObjCArrayLiteral(Elements, T, Method, SR); } ObjCArrayLiteral *ObjCArrayLiteral::CreateEmpty(const ASTContext &C, @@ -4124,13 +4121,11 @@ ObjCDictionaryLiteral::ObjCDictionaryLiteral( ArrayRef VK, bool HasPackExpansions, QualType T, ObjCMethodDecl *method, - ObjCMethodDecl *allocMethod, SourceRange SR) : Expr(ObjCDictionaryLiteralClass, T, VK_RValue, OK_Ordinary, false, false, false, false), NumElements(VK.size()), HasPackExpansions(HasPackExpansions), Range(SR), - DictWithObjectsMethod(method), - DictAllocMethod(allocMethod) + DictWithObjectsMethod(method) { KeyValuePair *KeyValues = getKeyValues(); ExpansionData *Expansions = getExpansionData(); @@ -4163,7 +4158,6 @@ ObjCDictionaryLiteral::Create(const ASTContext &C, ArrayRef VK, bool HasPackExpansions, QualType T, ObjCMethodDecl *method, - ObjCMethodDecl *allocMethod, SourceRange SR) { unsigned ExpansionsSize = 0; if (HasPackExpansions) @@ -4171,8 +4165,7 @@ ObjCDictionaryLiteral::Create(const ASTContext &C, void *Mem = C.Allocate(sizeof(ObjCDictionaryLiteral) + sizeof(KeyValuePair) * VK.size() + ExpansionsSize); - return new (Mem) ObjCDictionaryLiteral(VK, HasPackExpansions, T, - method, allocMethod, SR); + return new (Mem) ObjCDictionaryLiteral(VK, HasPackExpansions, T, method, SR); } ObjCDictionaryLiteral * diff --git a/clang/lib/AST/NSAPI.cpp b/clang/lib/AST/NSAPI.cpp index aac31e7..3dc750a 100644 --- a/clang/lib/AST/NSAPI.cpp +++ b/clang/lib/AST/NSAPI.cpp @@ -124,14 +124,6 @@ Selector NSAPI::getNSArraySelector(NSArrayMethodKind MK) const { Sel = Ctx.Selectors.getSelector(2, KeyIdents); break; } - case NSArr_initWithObjectsCount: { - IdentifierInfo *KeyIdents[] = { - &Ctx.Idents.get("initWithObjects"), - &Ctx.Idents.get("count") - }; - Sel = Ctx.Selectors.getSelector(2, KeyIdents); - break; - } } return (NSArraySelectors[MK] = Sel); } @@ -217,15 +209,6 @@ Selector NSAPI::getNSDictionarySelector( Sel = Ctx.Selectors.getSelector(2, KeyIdents); break; } - case NSDict_initWithObjectsForKeysCount: { - IdentifierInfo *KeyIdents[] = { - &Ctx.Idents.get("initWithObjects"), - &Ctx.Idents.get("forKeys"), - &Ctx.Idents.get("count") - }; - Sel = Ctx.Selectors.getSelector(3, KeyIdents); - break; - } } return (NSDictionarySelectors[MK] = Sel); } diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp index 164df93..ca67c4b 100644 --- a/clang/lib/CodeGen/CGObjC.cpp +++ b/clang/lib/CodeGen/CGObjC.cpp @@ -88,8 +88,7 @@ CodeGenFunction::EmitObjCBoxedExpr(const ObjCBoxedExpr *E) { } llvm::Value *CodeGenFunction::EmitObjCCollectionLiteral(const Expr *E, - const ObjCMethodDecl *MethodWithObjects, - const ObjCMethodDecl *AllocMethod) { + const ObjCMethodDecl *MethodWithObjects) { ASTContext &Context = CGM.getContext(); const ObjCDictionaryLiteral *DLE = nullptr; const ObjCArrayLiteral *ALE = dyn_cast(E); @@ -185,15 +184,6 @@ llvm::Value *CodeGenFunction::EmitObjCCollectionLiteral(const Expr *E, = InterfacePointerType->getObjectType()->getInterface(); CGObjCRuntime &Runtime = CGM.getObjCRuntime(); llvm::Value *Receiver = Runtime.GetClass(*this, Class); - if (AllocMethod) { - // Generate the "alloc" message send. - CallArgList Args; - Selector AllocMethodSel = AllocMethod->getSelector(); - RValue result = Runtime.GenerateMessageSend( - *this, ReturnValueSlot(), AllocMethod->getReturnType(), AllocMethodSel, - Receiver, Args, Class, AllocMethod); - Receiver = result.getScalarVal(); - } // Generate the message send. RValue result = Runtime.GenerateMessageSend( @@ -213,14 +203,12 @@ llvm::Value *CodeGenFunction::EmitObjCCollectionLiteral(const Expr *E, } llvm::Value *CodeGenFunction::EmitObjCArrayLiteral(const ObjCArrayLiteral *E) { - return EmitObjCCollectionLiteral(E, E->getArrayWithObjectsMethod(), - E->getArrayAllocMethod()); + return EmitObjCCollectionLiteral(E, E->getArrayWithObjectsMethod()); } llvm::Value *CodeGenFunction::EmitObjCDictionaryLiteral( const ObjCDictionaryLiteral *E) { - return EmitObjCCollectionLiteral(E, E->getDictWithObjectsMethod(), - E->getDictAllocMethod()); + return EmitObjCCollectionLiteral(E, E->getDictWithObjectsMethod()); } /// Emit a selector. diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index 80a7548..66f3fce 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -2392,8 +2392,7 @@ public: llvm::Value *EmitObjCArrayLiteral(const ObjCArrayLiteral *E); llvm::Value *EmitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E); llvm::Value *EmitObjCCollectionLiteral(const Expr *E, - const ObjCMethodDecl *MethodWithObjects, - const ObjCMethodDecl *AllocMethod); + const ObjCMethodDecl *MethodWithObjects); llvm::Value *EmitObjCSelectorExpr(const ObjCSelectorExpr *E); RValue EmitObjCMessageExpr(const ObjCMessageExpr *E, ReturnValueSlot Return = ReturnValueSlot()); diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index 901b669..63d7357 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -94,11 +94,7 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer, NSNumberDecl(nullptr), NSStringDecl(nullptr), StringWithUTF8StringMethod(nullptr), NSArrayDecl(nullptr), ArrayWithObjectsMethod(nullptr), - InitArrayWithObjectsMethod(nullptr), NSDictionaryDecl(nullptr), DictionaryWithObjectsMethod(nullptr), - InitDictionaryWithObjectsMethod(nullptr), - ArrayAllocObjectsMethod(nullptr), - DictAllocObjectsMethod(nullptr), MSAsmLabelNameCounter(0), GlobalNewDeleteDeclared(false), TUKind(TUKind), diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp index 40ab95b..ae9942b 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/lib/Sema/SemaExprObjC.cpp @@ -597,31 +597,6 @@ ExprResult Sema::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) { return MaybeBindToTemporary(BoxedExpr); } -static ObjCMethodDecl *FindAllocMethod(Sema &S, ObjCInterfaceDecl *NSClass) { - ObjCMethodDecl *Method = nullptr; - ASTContext &Context = S.Context; - - // Find +[NSClass alloc] method. - IdentifierInfo *II = &Context.Idents.get("alloc"); - Selector AllocSel = Context.Selectors.getSelector(0, &II); - Method = NSClass->lookupClassMethod(AllocSel); - if (!Method && S.getLangOpts().DebuggerObjCLiteral) { - Method = ObjCMethodDecl::Create(Context, - SourceLocation(), SourceLocation(), AllocSel, - Context.getObjCIdType(), - nullptr /*TypeSourceInfo */, - Context.getTranslationUnitDecl(), - false /*Instance*/, false/*isVariadic*/, - /*isPropertyAccessor=*/false, - /*isImplicitlyDeclared=*/true, /*isDefined=*/false, - ObjCMethodDecl::Required, - false); - SmallVector Params; - Method->setMethodParams(Context, Params, None); - } - return Method; -} - /// Build an ObjC subscript pseudo-object expression, given that /// that's supported by the runtime. ExprResult Sema::BuildObjCSubscriptExpression(SourceLocation RB, Expr *BaseExpr, @@ -655,7 +630,6 @@ ExprResult Sema::BuildObjCSubscriptExpression(SourceLocation RB, Expr *BaseExpr, } ExprResult Sema::BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements) { - bool Arc = getLangOpts().ObjCAutoRefCount; // Look up the NSArray class, if we haven't done so already. if (!NSArrayDecl) { NamedDecl *IF = LookupSingleName(TUScope, @@ -675,29 +649,18 @@ ExprResult Sema::BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements) { return ExprError(); } } - if (Arc && !ArrayAllocObjectsMethod) { - // Find +[NSArray alloc] method. - ArrayAllocObjectsMethod = FindAllocMethod(*this, NSArrayDecl); - if (!ArrayAllocObjectsMethod) { - Diag(SR.getBegin(), diag::err_undeclared_alloc); - return ExprError(); - } - } + // Find the arrayWithObjects:count: method, if we haven't done so already. QualType IdT = Context.getObjCIdType(); if (!ArrayWithObjectsMethod) { Selector - Sel = NSAPIObj->getNSArraySelector( - Arc? NSAPI::NSArr_initWithObjectsCount : NSAPI::NSArr_arrayWithObjectsCount); - ObjCMethodDecl *Method = - Arc? NSArrayDecl->lookupInstanceMethod(Sel) - : NSArrayDecl->lookupClassMethod(Sel); + Sel = NSAPIObj->getNSArraySelector(NSAPI::NSArr_arrayWithObjectsCount); + ObjCMethodDecl *Method = NSArrayDecl->lookupClassMethod(Sel); if (!Method && getLangOpts().DebuggerObjCLiteral) { TypeSourceInfo *ReturnTInfo = nullptr; Method = ObjCMethodDecl::Create( Context, SourceLocation(), SourceLocation(), Sel, IdT, ReturnTInfo, - Context.getTranslationUnitDecl(), - Arc /*Instance for Arc, Class for MRR*/, + Context.getTranslationUnitDecl(), false /*Instance*/, false /*isVariadic*/, /*isPropertyAccessor=*/false, /*isImplicitlyDeclared=*/true, /*isDefined=*/false, @@ -777,14 +740,12 @@ ExprResult Sema::BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements) { return MaybeBindToTemporary( ObjCArrayLiteral::Create(Context, Elements, Ty, - ArrayWithObjectsMethod, - ArrayAllocObjectsMethod, SR)); + ArrayWithObjectsMethod, SR)); } ExprResult Sema::BuildObjCDictionaryLiteral(SourceRange SR, ObjCDictionaryElement *Elements, unsigned NumElements) { - bool Arc = getLangOpts().ObjCAutoRefCount; // Look up the NSDictionary class, if we haven't done so already. if (!NSDictionaryDecl) { NamedDecl *IF = LookupSingleName(TUScope, @@ -804,32 +765,20 @@ ExprResult Sema::BuildObjCDictionaryLiteral(SourceRange SR, } } - if (Arc && !DictAllocObjectsMethod) { - // Find +[NSDictionary alloc] method. - DictAllocObjectsMethod = FindAllocMethod(*this, NSDictionaryDecl); - if (!DictAllocObjectsMethod) { - Diag(SR.getBegin(), diag::err_undeclared_alloc); - return ExprError(); - } - } - - // Find the dictionaryWithObjects:forKeys:count: or initWithObjects:forKeys:count: - // (for arc) method, if we haven't done so already. + // Find the dictionaryWithObjects:forKeys:count: method, if we haven't done + // so already. QualType IdT = Context.getObjCIdType(); if (!DictionaryWithObjectsMethod) { - Selector Sel = - NSAPIObj->getNSDictionarySelector(Arc? NSAPI::NSDict_initWithObjectsForKeysCount - : NSAPI::NSDict_dictionaryWithObjectsForKeysCount); - ObjCMethodDecl *Method = - Arc ? NSDictionaryDecl->lookupInstanceMethod(Sel) - : NSDictionaryDecl->lookupClassMethod(Sel); + Selector Sel = NSAPIObj->getNSDictionarySelector( + NSAPI::NSDict_dictionaryWithObjectsForKeysCount); + ObjCMethodDecl *Method = NSDictionaryDecl->lookupClassMethod(Sel); if (!Method && getLangOpts().DebuggerObjCLiteral) { Method = ObjCMethodDecl::Create(Context, SourceLocation(), SourceLocation(), Sel, IdT, nullptr /*TypeSourceInfo */, Context.getTranslationUnitDecl(), - Arc /*Instance for Arc, Class for MRR*/, false/*isVariadic*/, + false /*Instance*/, false/*isVariadic*/, /*isPropertyAccessor=*/false, /*isImplicitlyDeclared=*/true, /*isDefined=*/false, ObjCMethodDecl::Required, @@ -976,7 +925,7 @@ ExprResult Sema::BuildObjCDictionaryLiteral(SourceRange SR, Context.getObjCInterfaceType(NSDictionaryDecl)); return MaybeBindToTemporary(ObjCDictionaryLiteral::Create( Context, makeArrayRef(Elements, NumElements), HasPackExpansions, Ty, - DictionaryWithObjectsMethod, DictAllocObjectsMethod, SR)); + DictionaryWithObjectsMethod, SR)); } ExprResult Sema::BuildObjCEncodeExpression(SourceLocation AtLoc, diff --git a/clang/lib/Serialization/ASTReaderStmt.cpp b/clang/lib/Serialization/ASTReaderStmt.cpp index 5b4e12c..9e5593f 100644 --- a/clang/lib/Serialization/ASTReaderStmt.cpp +++ b/clang/lib/Serialization/ASTReaderStmt.cpp @@ -936,7 +936,6 @@ void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) { for (unsigned I = 0, N = NumElements; I != N; ++I) Elements[I] = Reader.ReadSubExpr(); E->ArrayWithObjectsMethod = ReadDeclAs(Record, Idx); - E->ArrayAllocMethod = ReadDeclAs(Record, Idx); E->Range = ReadSourceRange(Record, Idx); } @@ -957,7 +956,6 @@ void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) { } } E->DictWithObjectsMethod = ReadDeclAs(Record, Idx); - E->DictAllocMethod = ReadDeclAs(Record, Idx); E->Range = ReadSourceRange(Record, Idx); } diff --git a/clang/lib/Serialization/ASTWriterStmt.cpp b/clang/lib/Serialization/ASTWriterStmt.cpp index 18aad2f..99e7e6d 100644 --- a/clang/lib/Serialization/ASTWriterStmt.cpp +++ b/clang/lib/Serialization/ASTWriterStmt.cpp @@ -879,7 +879,6 @@ void ASTStmtWriter::VisitObjCArrayLiteral(ObjCArrayLiteral *E) { for (unsigned i = 0; i < E->getNumElements(); i++) Writer.AddStmt(E->getElement(i)); Writer.AddDeclRef(E->getArrayWithObjectsMethod(), Record); - Writer.AddDeclRef(E->getArrayAllocMethod(), Record); Writer.AddSourceRange(E->getSourceRange(), Record); Code = serialization::EXPR_OBJC_ARRAY_LITERAL; } @@ -902,7 +901,6 @@ void ASTStmtWriter::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) { } Writer.AddDeclRef(E->getDictWithObjectsMethod(), Record); - Writer.AddDeclRef(E->getDictAllocMethod(), Record); Writer.AddSourceRange(E->getSourceRange(), Record); Code = serialization::EXPR_OBJC_DICTIONARY_LITERAL; } diff --git a/clang/test/CodeGenObjC/Inputs/literal-support.h b/clang/test/CodeGenObjC/Inputs/literal-support.h index caa69c2..5680a20 100644 --- a/clang/test/CodeGenObjC/Inputs/literal-support.h +++ b/clang/test/CodeGenObjC/Inputs/literal-support.h @@ -3,10 +3,6 @@ typedef unsigned char BOOL; -@interface NSObject -+ (id)alloc; -@end - @interface NSNumber @end @interface NSNumber (NSNumberCreation) @@ -25,17 +21,15 @@ typedef unsigned char BOOL; + (NSNumber *)numberWithBool:(BOOL)value; @end -@interface NSArray : NSObject +@interface NSArray @end @interface NSArray (NSArrayCreation) + (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt; -- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt; @end -@interface NSDictionary : NSObject +@interface NSDictionary + (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -- (instancetype)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; @end #endif // OBJC_LITERAL_SUPPORT_H diff --git a/clang/test/CodeGenObjC/arc-literals.m b/clang/test/CodeGenObjC/arc-literals.m index 29f2b45..19a5516 100644 --- a/clang/test/CodeGenObjC/arc-literals.m +++ b/clang/test/CodeGenObjC/arc-literals.m @@ -8,8 +8,8 @@ // CHECK: c"numberWithUnsignedInt:\00" // CHECK: c"numberWithUnsignedLongLong:\00" // CHECK: c"numberWithChar:\00" -// CHECK: c"initWithObjects:count:\00" -// CHECK: c"initWithObjects:forKeys:count:\00" +// CHECK: c"arrayWithObjects:count:\00" +// CHECK: c"dictionaryWithObjects:forKeys:count:\00" // CHECK: c"prop\00" // CHECK-LABEL: define void @test_numeric() @@ -53,12 +53,10 @@ void test_array(id a, id b) { // CHECK-NEXT: [[T0:%.*]] = load [[CLASS_T:%.*]]** @"\01L_OBJC_CLASSLIST // CHECK-NEXT: [[SEL:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES // CHECK-NEXT: [[T1:%.*]] = bitcast [[CLASS_T]]* [[T0]] to i8* - - // CHECK-NEXT: [[ALLOC:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* [[T1]], i8* [[SEL]]) - // CHECK-NEXT: [[T9:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES - // CHECK-NEXT: [[T10:%.*]] = bitcast [2 x i8*]* [[OBJECTS]] to i8** - // CHECK-NEXT: [[ARRAYINIT:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*, i8**, i64)*)(i8* [[ALLOC]], i8* [[T9]], i8** [[T10]], i64 2) - // CHECK-NEXT: call void (...)* @clang.arc.use(i8* [[V0]], i8* [[V1]]) + // CHECK-NEXT: [[T2:%.*]] = bitcast [2 x i8*]* [[OBJECTS]] to i8** + // CHECK-NEXT: [[T3:%.*]] = call i8* bitcast ({{.*@objc_msgSend.*}})(i8* [[T1]], i8* [[SEL]], i8** [[T2]], i64 2) + // CHECK-NEXT: [[T4:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T3]]) + // CHECK: call void (...)* @clang.arc.use(i8* [[V0]], i8* [[V1]]) id arr = @[a, b]; // CHECK: call void @objc_release @@ -98,12 +96,10 @@ void test_dictionary(id k1, id o1, id k2, id o2) { // CHECK-NEXT: [[T0:%.*]] = load [[CLASS_T:%.*]]** @"\01L_OBJC_CLASSLIST // CHECK-NEXT: [[SEL:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES // CHECK-NEXT: [[T1:%.*]] = bitcast [[CLASS_T]]* [[T0]] to i8* - - // CHECK-NEXT: [[ALLOC:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* [[T1]], i8* [[SEL]]) - // CHECK-NEXT: [[T15:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES - // CHECK-NEXT: [[T16:%.*]] = bitcast [2 x i8*]* [[OBJECTS]] to i8** - // CHECK-NEXT: [[T17:%.*]] = bitcast [2 x i8*]* [[KEYS]] to i8** - // CHECK-NEXT: [[INIT:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*, i8**, i8**, i64)*)(i8* [[ALLOC]], i8* [[T15]], i8** [[T16]], i8** [[T17]], i64 2) + // CHECK-NEXT: [[T2:%.*]] = bitcast [2 x i8*]* [[OBJECTS]] to i8** + // CHECK-NEXT: [[T3:%.*]] = bitcast [2 x i8*]* [[KEYS]] to i8** + // CHECK-NEXT: [[T4:%.*]] = call i8* bitcast ({{.*@objc_msgSend.*}})(i8* [[T1]], i8* [[SEL]], i8** [[T2]], i8** [[T3]], i64 2) + // CHECK-NEXT: [[T5:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T4]]) // CHECK-NEXT: call void (...)* @clang.arc.use(i8* [[V0]], i8* [[V1]], i8* [[V2]], i8* [[V3]]) id dict = @{ k1 : o1, k2 : o2 }; @@ -142,15 +138,13 @@ void test_property(B *b) { // Store to array. // CHECK-NEXT: store i8* [[V1]], i8** [[T0]] - // Invoke initWithObjects:count: + // Invoke arrayWithObjects:count: // CHECK-NEXT: [[T0:%.*]] = load [[CLASS_T]]** @"\01L_OBJC_CLASSLIST // CHECK-NEXT: [[SEL:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES // CHECK-NEXT: [[T1:%.*]] = bitcast [[CLASS_T]]* [[T0]] to i8* - - // CHECK-NEXT: [[ALLOC:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* [[T1]], i8* [[SEL]]) - // CHECK-NEXT: [[T9:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES - // CHECK-NEXT: [[T10:%.*]] = bitcast [1 x i8*]* [[OBJECTS]] to i8** - // CHECK-NEXT: [[INIT:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*, i8**, i64)*)(i8* [[ALLOC]], i8* [[T9]], i8** [[T10]], i64 1) + // CHECK-NEXT: [[T2:%.*]] = bitcast [1 x i8*]* [[OBJECTS]] to i8** + // CHECK-NEXT: [[T3:%.*]] = call i8* bitcast ({{.*}} @objc_msgSend to {{.*}}(i8* [[T1]], i8* [[SEL]], i8** [[T2]], i64 1) + // CHECK-NEXT: call i8* @objc_retainAutoreleasedReturnValue(i8* [[T3]]) // CHECK-NEXT: call void (...)* @clang.arc.use(i8* [[V1]]) // CHECK-NEXT: bitcast // CHECK-NEXT: bitcast diff --git a/clang/test/CodeGenObjCXX/Inputs/literal-support.h b/clang/test/CodeGenObjCXX/Inputs/literal-support.h index 174ec3a..5680a20 100644 --- a/clang/test/CodeGenObjCXX/Inputs/literal-support.h +++ b/clang/test/CodeGenObjCXX/Inputs/literal-support.h @@ -3,10 +3,6 @@ typedef unsigned char BOOL; -@interface NSObject -+ (id)alloc; -@end - @interface NSNumber @end @interface NSNumber (NSNumberCreation) @@ -25,15 +21,14 @@ typedef unsigned char BOOL; + (NSNumber *)numberWithBool:(BOOL)value; @end -@interface NSArray : NSObject +@interface NSArray @end @interface NSArray (NSArrayCreation) + (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt; -- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt; @end -@interface NSDictionary : NSObject +@interface NSDictionary + (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; @end diff --git a/clang/test/CodeGenObjCXX/literals.mm b/clang/test/CodeGenObjCXX/literals.mm index 42ec4be..f21bba7 100644 --- a/clang/test/CodeGenObjCXX/literals.mm +++ b/clang/test/CodeGenObjCXX/literals.mm @@ -33,15 +33,8 @@ void test_array() { // CHECK: store i8* [[RET1]], i8** [[ELEMENT1]] // Build the array - // CHECK: [[T4:%.*]] = load [[CLASS:%.*]]** @"\01L_OBJC_CLASSLIST_REFERENCES_$_" - // CHECK-NEXT: [[T5:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_ - // CHECK-NEXT: [[T6:%.*]] = bitcast [[CLASS]]* [[T4]] to i8* - // CHECK-NEXT: [[ALLOC:%.*]] = {{invoke.*@objc_msgSend}} - - // CHECK: [[T7:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_ - // CHECK-NEXT: [[T8:%.*]] = bitcast [2 x i8*]* [[OBJECTS]] to i8** - // CHECK-NEXT: [[INIT:%.*]] = {{invoke.*@objc_msgSend}} - + // CHECK: {{invoke.*@objc_msgSend}} + // CHECK: call i8* @objc_retainAutoreleasedReturnValue id arr = @[ X(), Y() ]; // Destroy temporaries @@ -88,7 +81,7 @@ void test_array_instantiation() { // Build the array // CHECK: {{invoke.*@objc_msgSend}} - + // CHECK: call i8* @objc_retainAutoreleasedReturnValue id arr = @[ X(), Y() ]; // Destroy temporaries diff --git a/clang/test/SemaObjC/arc.m b/clang/test/SemaObjC/arc.m index 2816cef7..54a7db7 100644 --- a/clang/test/SemaObjC/arc.m +++ b/clang/test/SemaObjC/arc.m @@ -5,14 +5,9 @@ typedef const void * CFTypeRef; CFTypeRef CFBridgingRetain(id X); id CFBridgingRelease(CFTypeRef); @protocol NSCopying @end -@interface NSObject -+ (id)alloc; -@end - -@interface NSDictionary : NSObject +@interface NSDictionary + (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(NSUInteger)cnt; - (void)setObject:(id)object forKeyedSubscript:(id)key; -- (instancetype)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(NSUInteger)cnt; @end @class NSFastEnumerationState; @protocol NSFastEnumeration @@ -21,9 +16,8 @@ id CFBridgingRelease(CFTypeRef); @interface NSNumber + (NSNumber *)numberWithInt:(int)value; @end -@interface NSArray : NSObject +@interface NSArray + (id)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt; -- (id)initWithObjects:(const id [])objects count:(NSUInteger)cnt; @end void test0(void (*fn)(int), int val) { @@ -748,16 +742,16 @@ void _NSCalcBeze(NSColor* color, NSColor* bezelColors[]); // expected-error {{mu void rdar12569201(id key, id value) { // Declarations. __weak id x = @"foo"; // no-warning - __weak id y = @{ key : value }; // expected-warning {{assigning retained object to weak variable; object will be released after assignment}} - __weak id z = @[ value ]; // expected-warning {{assigning retained object to weak variable; object will be released after assignment}} + __weak id y = @{ key : value }; // expected-warning {{assigning dictionary literal to a weak variable; object will be released after assignment}} + __weak id z = @[ value ]; // expected-warning {{assigning array literal to a weak variable; object will be released after assignment}} __weak id b = ^() {}; // expected-warning {{assigning block literal to a weak variable; object will be released after assignment}} __weak id n = @42; // expected-warning {{assigning numeric literal to a weak variable; object will be released after assignment}} __weak id e = @(42); // expected-warning {{assigning numeric literal to a weak variable; object will be released after assignment}} __weak id m = @(41 + 1); // expected-warning {{assigning boxed expression to a weak variable; object will be released after assignment}} // Assignments. - y = @{ key : value }; // expected-warning {{assigning retained object to weak variable; object will be released after assignment}} - z = @[ value ]; // expected-warning {{assigning retained object to weak variable; object will be released after assignment}} + y = @{ key : value }; // expected-warning {{assigning dictionary literal to a weak variable; object will be released after assignment}} + z = @[ value ]; // expected-warning {{assigning array literal to a weak variable; object will be released after assignment}} b = ^() {}; // expected-warning {{assigning block literal to a weak variable; object will be released after assignment}} n = @42; // expected-warning {{assigning numeric literal to a weak variable; object will be released after assignment}} e = @(42); // expected-warning {{assigning numeric literal to a weak variable; object will be released after assignment}} diff --git a/clang/test/SemaObjC/objc-literal-comparison.m b/clang/test/SemaObjC/objc-literal-comparison.m index 409d713..95ebfb3 100644 --- a/clang/test/SemaObjC/objc-literal-comparison.m +++ b/clang/test/SemaObjC/objc-literal-comparison.m @@ -10,15 +10,12 @@ typedef signed char BOOL; -@protocol NSCopying @end - @interface BaseObject + (instancetype)new; @end @interface NSObject : BaseObject - (BOOL)isEqual:(id)other; -+ (id)alloc; @end @interface NSNumber : NSObject @@ -29,12 +26,10 @@ typedef signed char BOOL; @interface NSArray : NSObject + (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt; -- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt; @end @interface NSDictionary : NSObject + (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -- (instancetype)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; @end @interface NSString : NSObject diff --git a/clang/tools/libclang/IndexBody.cpp b/clang/tools/libclang/IndexBody.cpp index 30e1bff..5539971 100644 --- a/clang/tools/libclang/IndexBody.cpp +++ b/clang/tools/libclang/IndexBody.cpp @@ -109,9 +109,6 @@ public: if (ObjCMethodDecl *MD = E->getDictWithObjectsMethod()) IndexCtx.handleReference(MD, E->getLocStart(), Parent, ParentDC, E, CXIdxEntityRef_Implicit); - if (ObjCMethodDecl *MD = E->getDictAllocMethod()) - IndexCtx.handleReference(MD, E->getLocStart(), - Parent, ParentDC, E, CXIdxEntityRef_Implicit); return true; } @@ -119,9 +116,6 @@ public: if (ObjCMethodDecl *MD = E->getArrayWithObjectsMethod()) IndexCtx.handleReference(MD, E->getLocStart(), Parent, ParentDC, E, CXIdxEntityRef_Implicit); - if (ObjCMethodDecl *MD = E->getArrayAllocMethod()) - IndexCtx.handleReference(MD, E->getLocStart(), - Parent, ParentDC, E, CXIdxEntityRef_Implicit); return true; } -- 2.7.4