`getTypeSourceInfo()->getType()` and `getType()` are inconsistent for a constrained variable
#include <concepts>
void find(auto value) {
std::integral auto var = value;
}
Calling getTypeSourceInfo()->getType() and getType() result in two unique AutoTypes. If I have something like
v.getTypeSourceInfo()->getType()->dump();
v.getType()->dump();
the output is
AutoType 0x141b92c00 'integral auto' undeduced
`-Concept 0x141995a88 'integral'
AutoType 0x141b92d30 'integral auto' dependent
`-Concept 0x141995a88 'integral'
@llvm/issue-subscribers-clang-frontend
Author: Eric Li (tJener)
void find(auto value) { std::integral auto var = value; }
Calling `getTypeSourceInfo()->getType()` and `getType()` result in two unique `AutoType`s. If I have something like
```c++
v.getTypeSourceInfo()->getType()->dump();
v.getType()->dump();
the output is
AutoType 0x141b92c00 'integral auto' undeduced
`-Concept 0x141995a88 'integral'
AutoType 0x141b92d30 'integral auto' dependent
`-Concept 0x141995a88 'integral'
CC @mizvekov
Not a bug, this difference is expected.
The TypeSourceInfo is never deduced, it always contains the undeduced type. That explains the first dump:
AutoType 0x141b92c00 'integral auto' undeduced
`-Concept 0x141995a88 'integral'
Here the variable was deduced-as-dependent, which is expected since the initializer is dependent, so that explains your second dump:
AutoType 0x141b92d30 'integral auto' dependent
`-Concept 0x141995a88 'integral'
We keep track of these things separately because the deduced type is never used in template instantiation, we always perform deduction again from scratch, using the now instantiated initializer.
This is needed because a dependent type can not always be instantiated, because it may contain a DependentTy.
If we kept only the deduced type around, we would need to transform it back to undeduced when instantiating, so we save the undeduced type to avoid that.