[clang] [libcxx] [Clang] Add __common_type builtin (PR #99473)

Louis Dionne via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 19 06:55:11 PDT 2024


================
@@ -3058,6 +3058,141 @@ void Sema::NoteAllFoundTemplates(TemplateName Name) {
   }
 }
 
+static std::optional<QualType> commonTypeImpl(Sema &S,
+                                              TemplateName BaseTemplate,
+                                              SourceLocation TemplateLoc,
+                                              ArrayRef<TemplateArgument> Ts) {
+  auto lookUpCommonType = [&](TemplateArgument T1,
+                              TemplateArgument T2) -> std::optional<QualType> {
+    // Don't bother looking for other specializations if both types are
+    // builtins - users aren't allowed to specialize for them
+    if (T1.getAsType()->isBuiltinType() && T2.getAsType()->isBuiltinType())
+      return commonTypeImpl(S, BaseTemplate, TemplateLoc, {T1, T2});
----------------
ldionne wrote:

Isn't that infinite recursion?

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


More information about the cfe-commits mailing list