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

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to