[PATCH] D118350: [Clang][Sema][AIX][PowerPC] Emit byval alignment warning only when struct member is passed to a function

Zarko Todorovski via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 8 08:31:44 PST 2022


ZarkoCA added inline comments.


================
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:3299-3301
+    : Warning<" %0 byte requested alignment for a struct member used as an"
+              " argument is 16 bytes or greater which is not binary"
+              " compatible with IBM XL C/C++ for AIX 16.1.0 or older">,
----------------
aaron.ballman wrote:
> How about this slight rewording from the old form? (Have to re-flow to 80 cols.)
> 
> I had previously suggested adding the requested alignment before but now that we're closely tying the diagnostic to the structure member, I think this form is okay (and it's shorter, which is what I was hoping to accomplish).
Yes, I cringed a bit seeing it at 3 lines. Thanks. 


================
Comment at: clang/lib/Sema/SemaChecking.cpp:5221
+                << (unsigned)Alignment.getQuantity() << FD;
+            Diag(Loc, diag::note_called_by) << FD->getDeclName();
+          }
----------------
aaron.ballman wrote:
> I don't think this note is the correct one to use (it looks weird in the test cases). I think you'll want to add a new note along the lines of:
> ```
> def note_misaligned_member_used_here : Note<
>   "%0 used with potentially incompatible alignment here">;
> ```
> And you should pass in `FD` rather than `FD->getDeclName()` (the diagnostics engine knows how to print the names of `NamedDecl` subclasses and has special logic for that.
Ah yes, this seems much clearer to the user now IMO, thanks


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