[PATCH] D136018: [Clang] Fix crash when checking misaligned member with dependent type
Jun Zhang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 17 21:35:31 PDT 2022
junaire marked 5 inline comments as done.
junaire added inline comments.
================
Comment at: clang/lib/Sema/SemaChecking.cpp:17398-17399
+ const bool IsDiscardMisalignedPointer =
+ T->isPointerType() &&
+ (T->getPointeeType()->isIncompleteType() || T->isDependentType() ||
+ Context.getTypeAlignInChars(T->getPointeeType()) <= MA->Alignment);
----------------
aaron.ballman wrote:
> shafik wrote:
> > aaron.ballman wrote:
> > > Hmm, is this logic correct? Don't we want:
> > >
> > > ```
> > > T->isDependentType() ||
> > > (T->isPointerType() &&
> > > (T->getPointeeType()->isIncompleteType() || Context.getTypeAlignInChars(T->getPointeeType()) <= MA->Alignment))
> > > ```
> > Why did you drop the `T->isIntegerType()`?
> Whoops! That's totally a typo on my part, I didn't intend to drop it.
> Why did you drop the T->isIntegerType()?
There may be some misunderstanding here. So previously I hoist the pointer-related checks and put `T->isDependentType()` into it. After Aaron's words, I realized it was wrong so I changed the whole check condition to `is T an integer type? || is T a dependent type ?|| is T a pointer type and other constraints` (put them on the same level)
That said you're looking at the old diff so there's nothing need to worried about :)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D136018/new/
https://reviews.llvm.org/D136018
More information about the cfe-commits
mailing list