[clang-tools-extra] [clang-tidy] added `RespectOpaqueTypes` option to `readability-qualified-auto check` (PR #147060)
Juan Besa via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 8 08:55:26 PDT 2025
JuanBesa wrote:
I updated the Check to only modify the matcher. Will update tests + option name soon.
I have found a case which I don't know how to manage. The case is as follows (following tests format):
```
namespace std {
template <typename T>
class vector { // dummy impl
T _data[1];
public:
T *begin() { return _data; }
const T *begin() const { return _data; }
T *end() { return &_data[1]; }
const T *end() const { return &_data[1]; }
};
} // namespace std
void change(int&);
using IntPtr = int*; // Relevant typedef
void loopPtr(const std::vector<IntPtr> &VectorIntPtr) {
// Currently fails for RespectOpaqueTypes as AST does not have the IntPtr
for (auto Data : VectorIntPtr) {
change(*Data);
}
}
```
In this case when looking at the type of `Data` the `IntPtr` type does not appear, only `int*`
This is the AST of the type I see:
```
Binding for "inner":
AutoType 0x371dc570 'int *' sugar
`-SubstTemplateTypeParmType 0x371d7460 'int *' sugar typename depth 0 index 0 T
|-ClassTemplateSpecialization 0x371d6b40 'vector'
`-PointerType 0x371d69e0 'int *'
`-BuiltinType 0x37163260 'int'
```
I tried:
- Getting the template from the `SubstTemplateTypeParam` and from their getting the appropriate type. This also had `int *`!
- You can see the `IntPtr` in the For statement, but I don't know how to correctly get it from there for the appropriate type.
Godbolt link: https://godbolt.org/z/cxr536d7n
https://github.com/llvm/llvm-project/pull/147060
More information about the cfe-commits
mailing list