diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -7745,8 +7745,7 @@ /// enumeration_end - Past the last enumeration type found; iterator enumeration_end() { return EnumerationTypes.end(); } - iterator vector_begin() { return VectorTypes.begin(); } - iterator vector_end() { return VectorTypes.end(); } + llvm::iterator_range vector_types() { return VectorTypes; } llvm::iterator_range matrix_types() { return MatrixTypes; } @@ -8292,13 +8291,8 @@ } // Extension: We also add these operators for vector types. - for (BuiltinCandidateTypeSet::iterator - Vec = CandidateTypes[0].vector_begin(), - VecEnd = CandidateTypes[0].vector_end(); - Vec != VecEnd; ++Vec) { - QualType VecTy = *Vec; + for (QualType VecTy : CandidateTypes[0].vector_types()) S.AddBuiltinCandidate(&VecTy, Args, CandidateSet); - } } // C++ [over.built]p8: @@ -8332,13 +8326,8 @@ } // Extension: We also add this operator for vector types. - for (BuiltinCandidateTypeSet::iterator - Vec = CandidateTypes[0].vector_begin(), - VecEnd = CandidateTypes[0].vector_end(); - Vec != VecEnd; ++Vec) { - QualType VecTy = *Vec; + for (QualType VecTy : CandidateTypes[0].vector_types()) S.AddBuiltinCandidate(&VecTy, Args, CandidateSet); - } } // C++ [over.match.oper]p16: @@ -8569,18 +8558,11 @@ // Extension: Add the binary operators ==, !=, <, <=, >=, >, *, /, and the // conditional operator for vector types. - for (BuiltinCandidateTypeSet::iterator - Vec1 = CandidateTypes[0].vector_begin(), - Vec1End = CandidateTypes[0].vector_end(); - Vec1 != Vec1End; ++Vec1) { - for (BuiltinCandidateTypeSet::iterator - Vec2 = CandidateTypes[1].vector_begin(), - Vec2End = CandidateTypes[1].vector_end(); - Vec2 != Vec2End; ++Vec2) { - QualType LandR[2] = { *Vec1, *Vec2 }; + for (const QualType &Vec1Ty : CandidateTypes[0].vector_types()) + for (const QualType &Vec2Ty : CandidateTypes[1].vector_types()) { + QualType LandR[2] = {Vec1Ty, Vec2Ty}; S.AddBuiltinCandidate(LandR, Args, CandidateSet); } - } } /// Add binary operator overloads for each candidate matrix type M1, M2: @@ -8861,30 +8843,23 @@ } // Extension: Add the binary operators =, +=, -=, *=, /= for vector types. - for (BuiltinCandidateTypeSet::iterator - Vec1 = CandidateTypes[0].vector_begin(), - Vec1End = CandidateTypes[0].vector_end(); - Vec1 != Vec1End; ++Vec1) { - for (BuiltinCandidateTypeSet::iterator - Vec2 = CandidateTypes[1].vector_begin(), - Vec2End = CandidateTypes[1].vector_end(); - Vec2 != Vec2End; ++Vec2) { + for (const QualType &Vec1Ty : CandidateTypes[0].vector_types()) + for (const QualType &Vec2Ty : CandidateTypes[0].vector_types()) { QualType ParamTypes[2]; - ParamTypes[1] = *Vec2; + ParamTypes[1] = Vec2Ty; // Add this built-in operator as a candidate (VQ is empty). - ParamTypes[0] = S.Context.getLValueReferenceType(*Vec1); + ParamTypes[0] = S.Context.getLValueReferenceType(Vec1Ty); S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet, /*IsAssignmentOperator=*/isEqualOp); // Add this built-in operator as a candidate (VQ is 'volatile'). if (VisibleTypeConversionsQuals.hasVolatile()) { - ParamTypes[0] = S.Context.getVolatileType(*Vec1); + ParamTypes[0] = S.Context.getVolatileType(Vec1Ty); ParamTypes[0] = S.Context.getLValueReferenceType(ParamTypes[0]); S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet, /*IsAssignmentOperator=*/isEqualOp); } } - } } // C++ [over.built]p22: