[PATCH] D49511: [Sema/Attribute] Check for noderef attribute
Leonard Chan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 13 12:14:56 PDT 2018
leonardchan added a comment.
@rsmith
================
Comment at: lib/Sema/SemaExpr.cpp:14249
+
+ if (Sema::TypeHasNoDeref(Inner))
+ DeclRef = E;
----------------
aaron.ballman wrote:
> The sugar was stripped off at the pointer level, but not at the pointee level. e.g.,
> ```
> typedef int (bobble);
> typedef bobble * (frobble);
> typedef frobble * yobble;
>
> yobble gobble;
> ```
> I think you can handle this within `TypeHasNoDeref()` and that should fix up all the callers.
So `TypeHasNoDeref()` checks for the attribute on the base type already and is called after the pointer is stripped off. Attempting to desugar via `getDesugaredType()` here also removes the `address_space` attribute from the type I'm checking.
Do you know another method that essentially "expands" the typedefs without stripping the qualifiers? Otherwise I think I do need do the desugaring at the pointer level. Alternatively I could also change this method such that it accepts pointers instead of pointees since it appears I already call `getDesugaredType()` for almost every pointer who's pointee I'm passing to `TypeHasNoDeref()`.
Also I tested with your example and the warning still seems to be thrown appropriately.
Repository:
rC Clang
https://reviews.llvm.org/D49511
More information about the cfe-commits
mailing list