================
@@ -5262,6 +5256,24 @@ Sema::DeduceAutoType(TypeLoc Type, Expr *Init, QualType
&Result,
DeducedType = getDecltypeForExpr(Init);
assert(!DeducedType.isNull());
+ } else if (!InitList && !AT->isGNUAutoType() && !AT->isConstrained() &&
+ Context.hasSameType(Type.getType(), Context.AutoDeductTy) &&
+ !Init->getType()->isSpecificBuiltinType(BuiltinType::Overload) &&
+ Init->getType().isCanonical() &&
+ !Init->getType()->isObjCObjectPointerType()) {
----------------
Sirraide wrote:
A few notes: I think we can remove `!AT->isGNUAutoType() &&
!AT->isConstrained()`; use `Context.getAutoDeductTy()` instead of
`Context.AutoDeductTy`.
I think we should also apply this to non-canonical types, because it would be
nice for this to work with e.g. `std::int64_t`, which is a typedef and thus not
canonical.
We might also want to apply this to `auto*` and `const auto`, which I believe
mainly entails checking that the resulting type is a pointer type in the former
case and adding `const` in the latter.
I’m not sure what types exactly we need to exclude here or whether we should do
the opposite (i.e. instead of doing this for all types by default, only apply
this to a select few kinds of types).
https://github.com/llvm/llvm-project/pull/188196
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits