================
@@ -5324,13 +5384,35 @@ Sema::DeduceAutoType(TypeLoc Type, Expr *Init, QualType
&Result,
/*Decomposed=*/false, /*ArgIdx=*/0, /*TDF=*/0, FailedTSC);
TDK != TemplateDeductionResult::Success)
return TDK;
+
}
-
// Could be null if somehow 'auto' appears in a non-deduced context.
if (Deduced[0].getKind() != TemplateArgument::Type)
return TemplateDeductionResult::Incomplete;
DeducedType = Deduced[0].getAsType();
+#ifndef NDEBUG
+ if (FastPathUsed) {
+ // Ignore differences due only to QualType sugar.
----------------
heturing wrote:
I removed the call to getCanonicalType(). It was originally added to avoid
differences in type sugar representation (e.g., between `'Inc (*const[])[]'
sugar` and `'Inc (*const[])[]' const)`. However, I was not confident that
canonicalizing here would be safe for other cases, even though all the tests
passed. In this commit, I used a workaround for that specific case instead, so
the code now compares the deduced types directly.
Below is the debug output without the workaround for the case where the `Init`
is a pointer to an array and the code compares the deduced types directly.
Test case: clang/test/SemaCXX/cxx20-p0388-unbound-ary.cpp
```# | Deducing: PointerTypeLoc 'auto *'
# | -AutoTypeLoc 'auto' undeduced
# | DeclRefExpr 0x7a52b9da0 'Inc (*const (*)[])[]' lvalue Var 0x7a52b95a0 'r1'
'Inc (*const (*)[])[]'
# | Fast-path deduced type: ParenType 0x7a52b94b0 'Inc (*const[])[]' sugar
# | -IncompleteArrayType 0x7a52b9480 'Inc (*const[])[]'
# | -QualType 0x7a52b9421 'Inc (*const)[]' const
# | -PointerType 0x7a52b9420 'Inc (*)[]'
# | -ParenType 0x7a52b93c0 'Inc[]' sugar
# | -IncompleteArrayType 0x7a52b9390 'Inc[]'
# | -TypedefType 0x7a5293f00 'Inc' sugar
# | |-TypeAlias 0x7a5293ea0 'Inc'
# | -ConstantArrayType 0x7a5293e40 'int[2]' 2
# | -BuiltinType 0x7a50f3110 'int'
# | Slow-path deduced type: QualType 0x7a52b97a1 'Inc (*const[])[]' const
# | -IncompleteArrayType 0x7a52b97a0 'Inc (*[])[]'
# | -PointerType 0x7a52b9420 'Inc (*)[]'
# | -ParenType 0x7a52b93c0 'Inc[]' sugar
# | -IncompleteArrayType 0x7a52b9390 'Inc[]'
# | -TypedefType 0x7a5293f00 'Inc' sugar
# | |-TypeAlias 0x7a5293ea0 'Inc'
# | -ConstantArrayType 0x7a5293e40 'int[2]' 2
# | -BuiltinType 0x7a50f3110 'int'
```
https://github.com/llvm/llvm-project/pull/188196
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits