[clang] 714e84b - [SemaOverload] Use iterator_range to iterate over VectorTypes (NFC).
Florian Hahn via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 4 12:47:23 PDT 2020
Author: Florian Hahn
Date: 2020-06-04T20:47:16+01:00
New Revision: 714e84be4615d6e1195f2798c0c3c8c54017dd5f
URL: https://github.com/llvm/llvm-project/commit/714e84be4615d6e1195f2798c0c3c8c54017dd5f
DIFF: https://github.com/llvm/llvm-project/commit/714e84be4615d6e1195f2798c0c3c8c54017dd5f.diff
LOG: [SemaOverload] Use iterator_range to iterate over VectorTypes (NFC).
We can simplify the code a bit by using iterator_range instead of
plain iterators. Matrix type support here (added in 6f6e91d19337)
already uses an iterator_range.
Reviewers: rjmccall, arphaman, jfb, Bigcheese
Reviewed By: rjmccall
Differential Revision: https://reviews.llvm.org/D81138
Added:
Modified:
clang/lib/Sema/SemaOverload.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 11b6e40e8cd4..f3ac2036cb0d 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -7745,8 +7745,7 @@ class BuiltinCandidateTypeSet {
/// 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<iterator> vector_types() { return VectorTypes; }
llvm::iterator_range<iterator> matrix_types() { return MatrixTypes; }
@@ -8292,13 +8291,8 @@ class BuiltinOperatorOverloadBuilder {
}
// 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 @@ class BuiltinOperatorOverloadBuilder {
}
// 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 @@ class BuiltinOperatorOverloadBuilder {
// 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 (QualType Vec1Ty : CandidateTypes[0].vector_types())
+ for (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 @@ class BuiltinOperatorOverloadBuilder {
}
// 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 (QualType Vec1Ty : CandidateTypes[0].vector_types())
+ for (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:
More information about the cfe-commits
mailing list