diff options
author | Craig Topper <craig.topper@gmail.com> | 2015-12-24 23:58:15 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2015-12-24 23:58:15 +0000 |
commit | d4336e01d78316da868ef0bdb2524f2a6c712be0 (patch) | |
tree | 821c029909c6d06bad575d57f6fc4055496d84a4 /clang/lib | |
parent | 883dd332941f0966d3e5259e61118211b7fe26cd (diff) | |
download | bcm5719-llvm-d4336e01d78316da868ef0bdb2524f2a6c712be0.tar.gz bcm5719-llvm-d4336e01d78316da868ef0bdb2524f2a6c712be0.zip |
[Sema] ArrayRef-ize BuildObjCDictionaryLiteral. NFC
llvm-svn: 256398
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Parse/ParseObjc.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExprObjC.cpp | 29 | ||||
-rw-r--r-- | clang/lib/Sema/TreeTransform.h | 8 |
3 files changed, 18 insertions, 21 deletions
diff --git a/clang/lib/Parse/ParseObjc.cpp b/clang/lib/Parse/ParseObjc.cpp index 503c551200d..e72a1f62f94 100644 --- a/clang/lib/Parse/ParseObjc.cpp +++ b/clang/lib/Parse/ParseObjc.cpp @@ -3435,7 +3435,7 @@ ExprResult Parser::ParseObjCDictionaryLiteral(SourceLocation AtLoc) { // Create the ObjCDictionaryLiteral. return Actions.BuildObjCDictionaryLiteral(SourceRange(AtLoc, EndLoc), - Elements.data(), Elements.size()); + Elements); } /// objc-encode-expression: diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp index 863037d6de5..65f10816924 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/lib/Sema/SemaExprObjC.cpp @@ -865,9 +865,8 @@ ExprResult Sema::BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements) { ArrayWithObjectsMethod, SR)); } -ExprResult Sema::BuildObjCDictionaryLiteral(SourceRange SR, - ObjCDictionaryElement *Elements, - unsigned NumElements) { +ExprResult Sema::BuildObjCDictionaryLiteral(SourceRange SR, + MutableArrayRef<ObjCDictionaryElement> Elements) { SourceLocation Loc = SR.getBegin(); if (!NSDictionaryDecl) { @@ -1004,31 +1003,31 @@ ExprResult Sema::BuildObjCDictionaryLiteral(SourceRange SR, // Check that each of the keys and values provided is valid in a collection // literal, performing conversions as necessary. bool HasPackExpansions = false; - for (unsigned I = 0, N = NumElements; I != N; ++I) { + for (ObjCDictionaryElement &Element : Elements) { // Check the key. - ExprResult Key = CheckObjCCollectionLiteralElement(*this, Elements[I].Key, + ExprResult Key = CheckObjCCollectionLiteralElement(*this, Element.Key, KeyT); if (Key.isInvalid()) return ExprError(); // Check the value. ExprResult Value - = CheckObjCCollectionLiteralElement(*this, Elements[I].Value, ValueT); + = CheckObjCCollectionLiteralElement(*this, Element.Value, ValueT); if (Value.isInvalid()) return ExprError(); - Elements[I].Key = Key.get(); - Elements[I].Value = Value.get(); + Element.Key = Key.get(); + Element.Value = Value.get(); - if (Elements[I].EllipsisLoc.isInvalid()) + if (Element.EllipsisLoc.isInvalid()) continue; - if (!Elements[I].Key->containsUnexpandedParameterPack() && - !Elements[I].Value->containsUnexpandedParameterPack()) { - Diag(Elements[I].EllipsisLoc, + if (!Element.Key->containsUnexpandedParameterPack() && + !Element.Value->containsUnexpandedParameterPack()) { + Diag(Element.EllipsisLoc, diag::err_pack_expansion_without_parameter_packs) - << SourceRange(Elements[I].Key->getLocStart(), - Elements[I].Value->getLocEnd()); + << SourceRange(Element.Key->getLocStart(), + Element.Value->getLocEnd()); return ExprError(); } @@ -1040,7 +1039,7 @@ ExprResult Sema::BuildObjCDictionaryLiteral(SourceRange SR, = Context.getObjCObjectPointerType( Context.getObjCInterfaceType(NSDictionaryDecl)); return MaybeBindToTemporary(ObjCDictionaryLiteral::Create( - Context, makeArrayRef(Elements, NumElements), HasPackExpansions, Ty, + Context, Elements, HasPackExpansions, Ty, DictionaryWithObjectsMethod, SR)); } diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index e28b9dc8529..d7dcadd0aa7 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -2765,9 +2765,8 @@ public: /// By default, performs semantic analysis to build the new expression. /// Subclasses may override this routine to provide different behavior. ExprResult RebuildObjCDictionaryLiteral(SourceRange Range, - ObjCDictionaryElement *Elements, - unsigned NumElements) { - return getSema().BuildObjCDictionaryLiteral(Range, Elements, NumElements); + MutableArrayRef<ObjCDictionaryElement> Elements) { + return getSema().BuildObjCDictionaryLiteral(Range, Elements); } /// \brief Build a new Objective-C \@encode expression. @@ -10728,8 +10727,7 @@ TreeTransform<Derived>::TransformObjCDictionaryLiteral( return SemaRef.MaybeBindToTemporary(E); return getDerived().RebuildObjCDictionaryLiteral(E->getSourceRange(), - Elements.data(), - Elements.size()); + Elements); } template<typename Derived> |