[PATCH] D28166: Properly merge K&R functions that have attributes
Reid Kleckner via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 4 08:52:13 PST 2017
rnk added inline comments.
================
Comment at: lib/Sema/SemaDecl.cpp:11958-11962
+ // The type location may be attributed; strip the attributes to get to
+ // the function type location.
+ while (auto ATL = TL.getAs<AttributedTypeLoc>()) {
+ TL = ATL.getModifiedLoc();
+ }
----------------
rsmith wrote:
> Again, I don't like having this knowledge about what kinds of type sugar can appear in a function declaration hardcoded here. Please put this somewhere more central.
>
> A quick look finds that `FunctionDecl::getReturnTypeSourceRange()` gets this wrong in the opposite direction: it skips parens but not attributes. Maybe we should have a `TypeLoc::getAsAdjusted<T>` or similar, that walks over type sugar nodes that represent some kind of type adjustment from a type that was written as a T to another type that is still canonically a T (`ParenType`, `AttributedType`, `ElaboratedType`).
What about AdjustedType? You would see that in this case:
template <typename T> struct A {
T A::*method; // adjusted to __thiscall on i686-windows
};
template struct A<void()>;
Do you want to look through the __thiscall adjustment?
https://reviews.llvm.org/D28166
More information about the cfe-commits
mailing list