[PATCH] D116221: [AArch64][ARM][Clang] Unaligned Access Warning Added

Sam Elliott via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 4 06:51:57 PST 2022


lenary added a comment.

Two quick comments about when this is enabled, and then I'm happy!



================
Comment at: clang/lib/Driver/ToolChains/Arch/ARM.cpp:772-774
   if (KernelOrKext)
     Features.push_back("+strict-align");
   else if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access,
----------------
I think we should be enabling this warning everywhere we enable `+strict-align` between lines 772 and 813, even though in some of those cases an explicit argument has not been provided to the compiler to enable or disable unaligned accesses.

This should probably also be the case for aarch64 too!


================
Comment at: clang/lib/Driver/ToolChains/Arch/ARM.cpp:784-787
     } else
       Features.push_back("+strict-align");
+    CmdArgs.push_back("-Wunaligned-access");
   } else {
----------------
I think you want the curly braces here, as the condition on 774 is looking for both `-munaligned-access` and `-mno-unaligned-access`, and then line 776 checks which direction the last argument actually went. 


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D116221/new/

https://reviews.llvm.org/D116221



More information about the cfe-commits mailing list