[PATCH] D134286: [C2x] implement typeof and typeof_unqual
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 21 06:28:47 PDT 2022
aaron.ballman marked an inline comment as done.
aaron.ballman added inline comments.
================
Comment at: clang/lib/AST/Type.cpp:3504-3507
+ // We strip all qualifier-like attributes as well.
+ if (const auto *AT = dyn_cast<AttributedType>(Ret.getTypePtr());
+ AT && AT->isQualifier())
+ Ret = AT->getModifiedType();
----------------
mizvekov wrote:
> I think this block of code is not actually needed.
>
> So the AttributedType node is just sugar right, the address space are real qualifiers applied to the type, just like const and such.
>
> So the `getAtomicUnqualifiedType()` alone should do that, as it uses `getUnqualifiedType()` on the final result.
>
> When unqualifying a type, this will already strip all top level sugar nodes necessary to get rid of the qualifiers.
The situation I had in mind for this was something like:
```
typedef __attribute__((address_space(1))) int foo;
_Atomic foo i;
typeof_unqual(i) j; // Should be int
```
but I didn't realize we distribute the qualifiers from the inner type to the atomic type: https://godbolt.org/z/bbafvTKsj
So I think you're correct -- we don't seem to need this function at all. (Function type attributes like calling conventions, etc aren't handled via an `AttributedType` either, but are on the `ExtInfo` object for the function type.)
Good catch!
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D134286/new/
https://reviews.llvm.org/D134286
More information about the cfe-commits
mailing list