[PATCH] D105380: [clang] fixes named return of variables with dependent alignment
Aaron Puchert via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 5 14:21:41 PDT 2021
aaronpuchert added a comment.
I'd leave it to @rsmith to decide whether this makes sense in Sema.h.
I tend to follow the rule that if it's just used once I keep it local, but you might have good reasons for making it public.
================
Comment at: clang/lib/Sema/SemaDecl.cpp:13316
+ return VD->getType()->isDependentType() ||
+ std::any_of(range.begin(), range.end(), [](const AlignedAttr *AA) {
+ return AA->isAlignmentDependent();
----------------
>From `llvm/include/llvm/ADT/STLExtras.h`.
================
Comment at: clang/lib/Sema/SemaDecl.cpp:13317
+ std::any_of(range.begin(), range.end(), [](const AlignedAttr *I) {
+ return I->isAlignmentDependent();
+ });
----------------
mizvekov wrote:
> Quuxplusone wrote:
> > Tangent: It would be nice to rename `isAlignmentDependent` into `hasDependentAlignment` or simply `isDependent`. IIUC, the intended meaning is "Is this alignment attribute 'dependent'?" and not (as the name would naturally parse) "is this alignment attribute 'alignment-dependent'?"
> >
> > Arguably, it could also work to say `I->isDependentAlignment()` in the same way that we say `getType()->isDependentType()`.
> >
> > Speaking of which, maybe `I` should be renamed to `AA` or something? Is `I` really the right abbreviation for an `AlignedAttr`?
> I agree, but it is not so simple. This attribute class is autogenerated from `clang/include/clang/Basic/Attr.td` and it's not obvious to me where that method name comes from. Probably the tablegen backend. But that is another area that I am not familiar with yet.
> And there are a few users, and also a method named `isAlignmentErrorDependent` which would benefit from the same kind of rename.
> This DR is supposed to be a quick fix for a regression, I better leave that tangent for another time :)
>
> The second rename, well it is very common to name a predicate variable as `I`, but I renamed to `AA` as that is also good.
Seems plausible that it comes from
```
let Args = [ExprArgument<"Alignment">];
```
in `AlignValue`. An expression can be dependent, and to distinguish expression arguments, it probably generates functions `isXXXDependent` for `ExprArgument<"XXX">`. But I'm just guessing.
But yeah, nothing we can easily change here.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D105380/new/
https://reviews.llvm.org/D105380
More information about the cfe-commits
mailing list