@@ -8516,6 +8516,9 @@ class BuiltinCandidateTypeSet {
8516
8516
/// candidates.
8517
8517
TypeSet MatrixTypes;
8518
8518
8519
+ /// The set of _BitInt types that will be used in the built-in candidates.
8520
+ TypeSet BitIntTypes;
8521
+
8519
8522
/// A flag indicating non-record types are viable candidates
8520
8523
bool HasNonRecordTypes;
8521
8524
@@ -8564,6 +8567,7 @@ class BuiltinCandidateTypeSet {
8564
8567
}
8565
8568
llvm::iterator_range<iterator> vector_types() { return VectorTypes; }
8566
8569
llvm::iterator_range<iterator> matrix_types() { return MatrixTypes; }
8570
+ llvm::iterator_range<iterator> bitint_types() { return BitIntTypes; }
8567
8571
8568
8572
bool containsMatrixType(QualType Ty) const { return MatrixTypes.count(Ty); }
8569
8573
bool hasNonRecordTypes() { return HasNonRecordTypes; }
@@ -8735,6 +8739,9 @@ BuiltinCandidateTypeSet::AddTypesConvertedFrom(QualType Ty,
8735
8739
} else if (Ty->isEnumeralType()) {
8736
8740
HasArithmeticOrEnumeralTypes = true;
8737
8741
EnumerationTypes.insert(Ty);
8742
+ } else if (Ty->isBitIntType()) {
8743
+ HasArithmeticOrEnumeralTypes = true;
8744
+ BitIntTypes.insert(Ty);
8738
8745
} else if (Ty->isVectorType()) {
8739
8746
// We treat vector types as arithmetic types in many contexts as an
8740
8747
// extension.
@@ -8913,7 +8920,7 @@ class BuiltinOperatorOverloadBuilder {
8913
8920
SmallVectorImpl<BuiltinCandidateTypeSet> &CandidateTypes;
8914
8921
OverloadCandidateSet &CandidateSet;
8915
8922
8916
- static constexpr int ArithmeticTypesCap = 24 ;
8923
+ static constexpr int ArithmeticTypesCap = 26 ;
8917
8924
SmallVector<CanQualType, ArithmeticTypesCap> ArithmeticTypes;
8918
8925
8919
8926
// Define some indices used to iterate over the arithmetic types in
@@ -8955,6 +8962,20 @@ class BuiltinOperatorOverloadBuilder {
8955
8962
(S.Context.getAuxTargetInfo() &&
8956
8963
S.Context.getAuxTargetInfo()->hasInt128Type()))
8957
8964
ArithmeticTypes.push_back(S.Context.UnsignedInt128Ty);
8965
+
8966
+ /// We add candidates for the unique, unqualified _BitInt types present in
8967
+ /// the candidate type set. The candidate set already handled ensuring the
8968
+ /// type is unqualified and canonical, but because we're adding from N
8969
+ /// different sets, we need to do some extra work to unique things. Insert
8970
+ /// the candidates into a unique set, then move from that set into the list
8971
+ /// of arithmetic types.
8972
+ llvm::SmallSetVector<CanQualType, 2> BitIntCandidates;
8973
+ llvm::for_each(CandidateTypes, [&BitIntCandidates](
8974
+ BuiltinCandidateTypeSet &Candidate) {
8975
+ for (QualType BitTy : Candidate.bitint_types())
8976
+ BitIntCandidates.insert(CanQualType::CreateUnsafe(BitTy));
8977
+ });
8978
+ llvm::move(BitIntCandidates, std::back_inserter(ArithmeticTypes));
8958
8979
LastPromotedIntegralType = ArithmeticTypes.size();
8959
8980
LastPromotedArithmeticType = ArithmeticTypes.size();
8960
8981
// End of promoted types.
@@ -8975,7 +8996,11 @@ class BuiltinOperatorOverloadBuilder {
8975
8996
// End of integral types.
8976
8997
// FIXME: What about complex? What about half?
8977
8998
8978
- assert(ArithmeticTypes.size() <= ArithmeticTypesCap &&
8999
+ // We don't know for sure how many bit-precise candidates were involved, so
9000
+ // we subtract those from the total when testing whether we're under the
9001
+ // cap or not.
9002
+ assert(ArithmeticTypes.size() - BitIntCandidates.size() <=
9003
+ ArithmeticTypesCap &&
8979
9004
"Enough inline storage for all arithmetic types.");
8980
9005
}
8981
9006
0 commit comments