[PATCH] D118350: [Clang][Sema][AIX][PowerPC] Emit byval alignment warning only when struct is passed to a function
Sean Fertile via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 8 07:27:40 PST 2022
sfertile added a comment.
Thanks for the updates Zarko. I think we are almost there.
================
Comment at: clang/lib/Sema/SemaChecking.cpp:5242
+// Here we try to get information about the alignment of the struct member
+// from the struct passed to the caller function.We only warn when the struct
+// is passed byval, hence the series of checks and early returns if we are a not
----------------
Real minor nit: Missing space after period.
================
Comment at: clang/lib/Sema/SemaChecking.cpp:5255
+ const auto *PVD = dyn_cast<ParmVarDecl>(
+ (dyn_cast<DeclRefExpr>(
+ (dyn_cast<ImplicitCastExpr>(Arg->IgnoreParens()))->getSubExpr()))
----------------
I find these longer lines hard to read. I way you had the original checks structured was good, my suggestion was really meant to change only the nesting. I think keeping the same format you would have ended up with something that looks like
```
const auto *ICE = dyn_cast<ImplicitCastExpr>(Arg->IgnoreParens());
if (!ICE)
return;
const auto *DR = dyn_cast<DeclRefExpr>(ICE->getSubExpr());
if (!DR)
return;
auto *PD = dyn_cast<ParmVarDecl>(DR->getDecl();
if (!PD || !PD->getType()->isRecordType())
return;
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D118350/new/
https://reviews.llvm.org/D118350
More information about the cfe-commits
mailing list