[clang] [Sema] Fix false positive warnings for misaligned member access (PR #150025)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 24 06:22:30 PDT 2025
================
@@ -15534,17 +15534,28 @@ void Sema::AddPotentialMisalignedMembers(Expr *E, RecordDecl *RD, ValueDecl *MD,
MisalignedMembers.emplace_back(E, RD, MD, Alignment);
}
-void Sema::DiagnoseMisalignedMembers() {
- for (MisalignedMember &m : MisalignedMembers) {
- const NamedDecl *ND = m.RD;
+void Sema::DiagnoseMisalignedMembers(const Expr *E) {
+ // Only emit diagnostics related to the current expression.
+ const auto *EmitFrom = MisalignedMembers.begin();
+ if (E->getSourceRange().isValid()) {
----------------
erichkeane wrote:
This is not really a valid way to do this, all of the checking source locations isn't really something Sema should be doing.
How exactly is this trying to work? It seems that the diagnostic you're trying to skip actually lloks valid, and I don't see how looking at source locations helps?
https://github.com/llvm/llvm-project/pull/150025
More information about the cfe-commits
mailing list