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<Expr *> Elements,
QualType T, ObjCMethodDecl * Method,
+ ObjCMethodDecl *allocMethod,
SourceRange SR);
explicit ObjCArrayLiteral(EmptyShell Empty, unsigned NumElements)
static ObjCArrayLiteral *Create(const ASTContext &C,
ArrayRef<Expr *> Elements,
QualType T, ObjCMethodDecl * Method,
+ ObjCMethodDecl *allocMethod,
SourceRange SR);
static ObjCArrayLiteral *CreateEmpty(const ASTContext &C,
return ArrayWithObjectsMethod;
}
+ ObjCMethodDecl *getArrayAllocMethod() const {
+ return ArrayAllocMethod;
+ }
+
// Iterators
child_range children() {
return child_range((Stmt **)getElements(),
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<ObjCDictionaryElement> VK,
bool HasPackExpansions,
QualType T, ObjCMethodDecl *method,
+ ObjCMethodDecl *allocMethod,
SourceRange SR);
explicit ObjCDictionaryLiteral(EmptyShell Empty, unsigned NumElements,
ArrayRef<ObjCDictionaryElement> VK,
bool HasPackExpansions,
QualType T, ObjCMethodDecl *method,
+ ObjCMethodDecl *allocMethod,
SourceRange SR);
static ObjCDictionaryLiteral *CreateEmpty(const ASTContext &C,
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; }
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)
+ NumElements(Elements.size()), Range(SR), ArrayWithObjectsMethod(Method),
+ ArrayAllocMethod(AllocMethod)
{
Expr **SaveElements = getElements();
for (unsigned I = 0, N = Elements.size(); I != N; ++I) {
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, SR);
+ return new (Mem) ObjCArrayLiteral(Elements, T, Method, allocMethod, SR);
}
ObjCArrayLiteral *ObjCArrayLiteral::CreateEmpty(const ASTContext &C,
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)
+ DictWithObjectsMethod(method),
+ DictAllocMethod(allocMethod)
{
KeyValuePair *KeyValues = getKeyValues();
ExpansionData *Expansions = getExpansionData();
ArrayRef<ObjCDictionaryElement> VK,
bool HasPackExpansions,
QualType T, ObjCMethodDecl *method,
+ ObjCMethodDecl *allocMethod,
SourceRange SR) {
unsigned ExpansionsSize = 0;
if (HasPackExpansions)
void *Mem = C.Allocate(sizeof(ObjCDictionaryLiteral) +
sizeof(KeyValuePair) * VK.size() + ExpansionsSize);
- return new (Mem) ObjCDictionaryLiteral(VK, HasPackExpansions, T, method, SR);
+ return new (Mem) ObjCDictionaryLiteral(VK, HasPackExpansions, T,
+ method, allocMethod, SR);
}
ObjCDictionaryLiteral *
}
llvm::Value *CodeGenFunction::EmitObjCCollectionLiteral(const Expr *E,
- const ObjCMethodDecl *MethodWithObjects) {
+ const ObjCMethodDecl *MethodWithObjects,
+ const ObjCMethodDecl *AllocMethod) {
ASTContext &Context = CGM.getContext();
const ObjCDictionaryLiteral *DLE = nullptr;
const ObjCArrayLiteral *ALE = dyn_cast<ObjCArrayLiteral>(E);
}
llvm::Value *CodeGenFunction::EmitObjCArrayLiteral(const ObjCArrayLiteral *E) {
- return EmitObjCCollectionLiteral(E, E->getArrayWithObjectsMethod());
+ return EmitObjCCollectionLiteral(E, E->getArrayWithObjectsMethod(),
+ E->getArrayAllocMethod());
}
llvm::Value *CodeGenFunction::EmitObjCDictionaryLiteral(
const ObjCDictionaryLiteral *E) {
- return EmitObjCCollectionLiteral(E, E->getDictWithObjectsMethod());
+ return EmitObjCCollectionLiteral(E, E->getDictWithObjectsMethod(),
+ E->getDictAllocMethod());
}
/// Emit a selector.
llvm::Value *EmitObjCArrayLiteral(const ObjCArrayLiteral *E);
llvm::Value *EmitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E);
llvm::Value *EmitObjCCollectionLiteral(const Expr *E,
- const ObjCMethodDecl *MethodWithObjects);
+ const ObjCMethodDecl *MethodWithObjects,
+ const ObjCMethodDecl *AllocMethod);
llvm::Value *EmitObjCSelectorExpr(const ObjCSelectorExpr *E);
RValue EmitObjCMessageExpr(const ObjCMessageExpr *E,
ReturnValueSlot Return = ReturnValueSlot());
return MaybeBindToTemporary(
ObjCArrayLiteral::Create(Context, Elements, Ty,
- ArrayWithObjectsMethod, SR));
+ ArrayWithObjectsMethod, nullptr, SR));
}
ExprResult Sema::BuildObjCDictionaryLiteral(SourceRange SR,
Context.getObjCInterfaceType(NSDictionaryDecl));
return MaybeBindToTemporary(ObjCDictionaryLiteral::Create(
Context, makeArrayRef(Elements, NumElements), HasPackExpansions, Ty,
- DictionaryWithObjectsMethod, SR));
+ DictionaryWithObjectsMethod, nullptr, SR));
}
ExprResult Sema::BuildObjCEncodeExpression(SourceLocation AtLoc,
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);
}
}
}
E->DictWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
+ E->DictAllocMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
E->Range = ReadSourceRange(Record, Idx);
}
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;
}
}
Writer.AddDeclRef(E->getDictWithObjectsMethod(), Record);
+ Writer.AddDeclRef(E->getDictAllocMethod(), Record);
Writer.AddSourceRange(E->getSourceRange(), Record);
Code = serialization::EXPR_OBJC_DICTIONARY_LITERAL;
}
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;
}
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;
}