summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/Expr.cpp15
-rw-r--r--clang/lib/AST/NSAPI.cpp17
-rw-r--r--clang/lib/CodeGen/CGObjC.cpp18
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.h3
-rw-r--r--clang/lib/Sema/Sema.cpp4
-rw-r--r--clang/lib/Sema/SemaExprObjC.cpp75
-rw-r--r--clang/lib/Serialization/ASTReaderStmt.cpp2
-rw-r--r--clang/lib/Serialization/ASTWriterStmt.cpp2
8 files changed, 20 insertions, 116 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index ec679f0669a..a76d50576aa 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<Expr *> 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<Expr *> Elements,
ObjCArrayLiteral *ObjCArrayLiteral::Create(const ASTContext &C,
ArrayRef<Expr *> 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<ObjCDictionaryElement> 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<ObjCDictionaryElement> 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 aac31e7f15c..3dc750a8178 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 164df93e314..ca67c4bd1c1 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<ObjCArrayLiteral>(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 80a7548561e..66f3fcecff7 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 901b669e6d4..63d7357505a 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 40ab95b6ec5..ae9942b1c3e 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<ParmVarDecl *, 1> 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 5b4e12cbb45..9e5593fc9e0 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<ObjCMethodDecl>(Record, Idx);
- E->ArrayAllocMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
E->Range = ReadSourceRange(Record, Idx);
}
@@ -957,7 +956,6 @@ void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
}
}
E->DictWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
- E->DictAllocMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
E->Range = ReadSourceRange(Record, Idx);
}
diff --git a/clang/lib/Serialization/ASTWriterStmt.cpp b/clang/lib/Serialization/ASTWriterStmt.cpp
index 18aad2ffe8b..99e7e6d2ef0 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;
}
OpenPOWER on IntegriCloud