[clang] Add bit-precise overloads for builtin operators (PR #84755)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 11 09:26:55 PDT 2024


================
@@ -8955,6 +8962,22 @@ class BuiltinOperatorOverloadBuilder {
         (S.Context.getAuxTargetInfo() &&
          S.Context.getAuxTargetInfo()->hasInt128Type()))
       ArithmeticTypes.push_back(S.Context.UnsignedInt128Ty);
+
+    /// _BitInt overloads are a bit special. We don't want to add candidates
+    /// for the entire family of _BitInt types, so instead we only add
+    /// candidates for the unique, unqualified _BitInt types present in the
+    /// candidate type set. The candidate set already handled ensuring the type
+    /// is unqualified and canonical, but because we're adding from N different
+    /// sets, we need to do some extra work to unique things. Copy the
+    /// candidates into a unique set, then copy from that set into the list of
+    /// arithmetic types.
+    llvm::SmallSetVector<CanQualType, 2> BitIntCandidates;
+    llvm::for_each(CandidateTypes, [&BitIntCandidates](
+                                       BuiltinCandidateTypeSet &Candidate) {
+      for (QualType BitTy : Candidate.bitint_types())
+        BitIntCandidates.insert(CanQualType::CreateUnsafe(BitTy));
+    });
+    llvm::copy(BitIntCandidates, std::back_inserter(ArithmeticTypes));
----------------
AaronBallman wrote:

Done

https://github.com/llvm/llvm-project/pull/84755


More information about the cfe-commits mailing list