Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 4c7c3a1

Browse files
committed
[Sema] ArrayRef-ize BuildObjCDictionaryLiteral. NFC
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256398 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent af550de commit 4c7c3a1

File tree

4 files changed

+19
-23
lines changed

4 files changed

+19
-23
lines changed

Diff for: include/clang/Sema/Sema.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -5112,8 +5112,7 @@ class Sema {
51125112
ObjCMethodDecl *setterMethod);
51135113

51145114
ExprResult BuildObjCDictionaryLiteral(SourceRange SR,
5115-
ObjCDictionaryElement *Elements,
5116-
unsigned NumElements);
5115+
MutableArrayRef<ObjCDictionaryElement> Elements);
51175116

51185117
ExprResult BuildObjCEncodeExpression(SourceLocation AtLoc,
51195118
TypeSourceInfo *EncodedTypeInfo,

Diff for: lib/Parse/ParseObjc.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3435,7 +3435,7 @@ ExprResult Parser::ParseObjCDictionaryLiteral(SourceLocation AtLoc) {
34353435

34363436
// Create the ObjCDictionaryLiteral.
34373437
return Actions.BuildObjCDictionaryLiteral(SourceRange(AtLoc, EndLoc),
3438-
Elements.data(), Elements.size());
3438+
Elements);
34393439
}
34403440

34413441
/// objc-encode-expression:

Diff for: lib/Sema/SemaExprObjC.cpp

+14-15
Original file line numberDiff line numberDiff line change
@@ -865,9 +865,8 @@ ExprResult Sema::BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements) {
865865
ArrayWithObjectsMethod, SR));
866866
}
867867

868-
ExprResult Sema::BuildObjCDictionaryLiteral(SourceRange SR,
869-
ObjCDictionaryElement *Elements,
870-
unsigned NumElements) {
868+
ExprResult Sema::BuildObjCDictionaryLiteral(SourceRange SR,
869+
MutableArrayRef<ObjCDictionaryElement> Elements) {
871870
SourceLocation Loc = SR.getBegin();
872871

873872
if (!NSDictionaryDecl) {
@@ -1004,31 +1003,31 @@ ExprResult Sema::BuildObjCDictionaryLiteral(SourceRange SR,
10041003
// Check that each of the keys and values provided is valid in a collection
10051004
// literal, performing conversions as necessary.
10061005
bool HasPackExpansions = false;
1007-
for (unsigned I = 0, N = NumElements; I != N; ++I) {
1006+
for (ObjCDictionaryElement &Element : Elements) {
10081007
// Check the key.
1009-
ExprResult Key = CheckObjCCollectionLiteralElement(*this, Elements[I].Key,
1008+
ExprResult Key = CheckObjCCollectionLiteralElement(*this, Element.Key,
10101009
KeyT);
10111010
if (Key.isInvalid())
10121011
return ExprError();
10131012

10141013
// Check the value.
10151014
ExprResult Value
1016-
= CheckObjCCollectionLiteralElement(*this, Elements[I].Value, ValueT);
1015+
= CheckObjCCollectionLiteralElement(*this, Element.Value, ValueT);
10171016
if (Value.isInvalid())
10181017
return ExprError();
10191018

1020-
Elements[I].Key = Key.get();
1021-
Elements[I].Value = Value.get();
1019+
Element.Key = Key.get();
1020+
Element.Value = Value.get();
10221021

1023-
if (Elements[I].EllipsisLoc.isInvalid())
1022+
if (Element.EllipsisLoc.isInvalid())
10241023
continue;
10251024

1026-
if (!Elements[I].Key->containsUnexpandedParameterPack() &&
1027-
!Elements[I].Value->containsUnexpandedParameterPack()) {
1028-
Diag(Elements[I].EllipsisLoc,
1025+
if (!Element.Key->containsUnexpandedParameterPack() &&
1026+
!Element.Value->containsUnexpandedParameterPack()) {
1027+
Diag(Element.EllipsisLoc,
10291028
diag::err_pack_expansion_without_parameter_packs)
1030-
<< SourceRange(Elements[I].Key->getLocStart(),
1031-
Elements[I].Value->getLocEnd());
1029+
<< SourceRange(Element.Key->getLocStart(),
1030+
Element.Value->getLocEnd());
10321031
return ExprError();
10331032
}
10341033

@@ -1040,7 +1039,7 @@ ExprResult Sema::BuildObjCDictionaryLiteral(SourceRange SR,
10401039
= Context.getObjCObjectPointerType(
10411040
Context.getObjCInterfaceType(NSDictionaryDecl));
10421041
return MaybeBindToTemporary(ObjCDictionaryLiteral::Create(
1043-
Context, makeArrayRef(Elements, NumElements), HasPackExpansions, Ty,
1042+
Context, Elements, HasPackExpansions, Ty,
10441043
DictionaryWithObjectsMethod, SR));
10451044
}
10461045

Diff for: lib/Sema/TreeTransform.h

+3-5
Original file line numberDiff line numberDiff line change
@@ -2765,9 +2765,8 @@ class TreeTransform {
27652765
/// By default, performs semantic analysis to build the new expression.
27662766
/// Subclasses may override this routine to provide different behavior.
27672767
ExprResult RebuildObjCDictionaryLiteral(SourceRange Range,
2768-
ObjCDictionaryElement *Elements,
2769-
unsigned NumElements) {
2770-
return getSema().BuildObjCDictionaryLiteral(Range, Elements, NumElements);
2768+
MutableArrayRef<ObjCDictionaryElement> Elements) {
2769+
return getSema().BuildObjCDictionaryLiteral(Range, Elements);
27712770
}
27722771

27732772
/// \brief Build a new Objective-C \@encode expression.
@@ -10728,8 +10727,7 @@ TreeTransform<Derived>::TransformObjCDictionaryLiteral(
1072810727
return SemaRef.MaybeBindToTemporary(E);
1072910728

1073010729
return getDerived().RebuildObjCDictionaryLiteral(E->getSourceRange(),
10731-
Elements.data(),
10732-
Elements.size());
10730+
Elements);
1073310731
}
1073410732

1073510733
template<typename Derived>

0 commit comments

Comments
 (0)