[PATCH] D78767: [Sema] Teach -Wcast-align to compute a more accurate alignment when the source expression has array subscript or pointer arithmetic operators

2020-05-15 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rG854f5f332af4: [Sema] Teach -Wcast-align to compute an accurate alignment using the alignment… (authored by ahatanak). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION

[PATCH] D78767: [Sema] Teach -Wcast-align to compute a more accurate alignment when the source expression has array subscript or pointer arithmetic operators

2020-05-15 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision. rjmccall added a comment. This revision is now accepted and ready to land. LGTM. Comment at: clang/lib/Sema/SemaChecking.cpp:13122 +if (Base->isVirtual()) { + BaseAlignment = Ctx.getTypeAlignInChars(Base->getType()); + Offset =

[PATCH] D78767: [Sema] Teach -Wcast-align to compute a more accurate alignment when the source expression has array subscript or pointer arithmetic operators

2020-05-14 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments. Comment at: clang/lib/Sema/SemaChecking.cpp:13122 +if (Base->isVirtual()) { + BaseAlignment = Ctx.getTypeAlignInChars(Base->getType()); + Offset = CharUnits::Zero(); rjmccall wrote: > ahatanak wrote: > > rjmccall

[PATCH] D78767: [Sema] Teach -Wcast-align to compute a more accurate alignment when the source expression has array subscript or pointer arithmetic operators

2020-05-14 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 264157. ahatanak marked 2 inline comments as done. ahatanak added a comment. Fix alignment computation of virtual bases. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D78767/new/

[PATCH] D78767: [Sema] Teach -Wcast-align to compute a more accurate alignment when the source expression has array subscript or pointer arithmetic operators

2020-05-14 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment. Other changes look good to me, thanks. Comment at: clang/lib/Sema/SemaChecking.cpp:13122 +if (Base->isVirtual()) { + BaseAlignment = Ctx.getTypeAlignInChars(Base->getType()); + Offset = CharUnits::Zero(); ahatanak wrote:

[PATCH] D78767: [Sema] Teach -Wcast-align to compute a more accurate alignment when the source expression has array subscript or pointer arithmetic operators

2020-05-14 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments. Comment at: clang/lib/Sema/SemaChecking.cpp:13122 +if (Base->isVirtual()) { + BaseAlignment = Ctx.getTypeAlignInChars(Base->getType()); + Offset = CharUnits::Zero(); rjmccall wrote: > Oh, this — and all the other

[PATCH] D78767: [Sema] Teach -Wcast-align to compute a more accurate alignment when the source expression has array subscript or pointer arithmetic operators

2020-05-14 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 264106. ahatanak marked 8 inline comments as done. ahatanak added a comment. Address most of the review comments. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D78767/new/ https://reviews.llvm.org/D78767

[PATCH] D78767: [Sema] Teach -Wcast-align to compute a more accurate alignment when the source expression has array subscript or pointer arithmetic operators

2020-05-13 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments. Comment at: clang/lib/Sema/SemaChecking.cpp:13122 +if (Base->isVirtual()) { + BaseAlignment = Ctx.getTypeAlignInChars(Base->getType()); + Offset = CharUnits::Zero(); Oh, this — and all the other places that do

[PATCH] D78767: [Sema] Teach -Wcast-align to compute a more accurate alignment when the source expression has array subscript or pointer arithmetic operators

2020-05-13 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 263753. ahatanak marked 6 inline comments as done. ahatanak added a comment. Address review comments. Handle derived-to-base cast expressions and array subscript expressions that don't have constant indices. Repository: rG LLVM Github Monorepo CHANGES

[PATCH] D78767: [Sema] Teach -Wcast-align to compute a more accurate alignment when the source expression has array subscript or pointer arithmetic operators

2020-05-12 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments. Comment at: clang/lib/Sema/SemaChecking.cpp:13111 + } + } + return std::make_tuple(false, CharUnits::Zero(), CharUnits::Zero()); ahatanak wrote: > rjmccall wrote: > > Derived-to-base conversions. > Does this include cases where

[PATCH] D78767: [Sema] Teach -Wcast-align to compute a more accurate alignment when the source expression has array subscript or pointer arithmetic operators

2020-05-12 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak marked an inline comment as done. ahatanak added inline comments. Comment at: clang/lib/Sema/SemaChecking.cpp:13111 + } + } + return std::make_tuple(false, CharUnits::Zero(), CharUnits::Zero()); rjmccall wrote: > Derived-to-base conversions. Does

[PATCH] D78767: [Sema] Teach -Wcast-align to compute a more accurate alignment when the source expression has array subscript or pointer arithmetic operators

2020-05-11 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments. Comment at: clang/lib/Sema/SemaChecking.cpp:13066 +std::tuple +static getBaseAlignmentAndOffsetFromLValue(const Expr *E, ASTContext ) { + E = E->IgnoreParens(); I think an `Optional` would be a more self-documenting type here,

[PATCH] D78767: [Sema] Teach -Wcast-align to compute a more accurate alignment when the source expression has array subscript or pointer arithmetic operators

2020-05-11 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 263238. ahatanak marked an inline comment as done. ahatanak added a comment. Define two helper functions in Sema that compute the alignment of a VarDecl and a constant offset from it and use them instead of the classes for evaluating lvalue and pointer

[PATCH] D78767: [Sema] Teach -Wcast-align to compute a more accurate alignment when the source expression has array subscript or pointer arithmetic operators

2020-04-27 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak planned changes to this revision. ahatanak added a comment. The method has to compute the correct alignment for variables captured by lambdas or blocks too. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D78767/new/

[PATCH] D78767: [Sema] Teach -Wcast-align to compute a more accurate alignment when the source expression has array subscript or pointer arithmetic operators

2020-04-24 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak marked an inline comment as done. ahatanak added inline comments. Comment at: clang/lib/AST/ExprConstant.cpp:14844 + if (auto *VD = Result.Base.dyn_cast()) +return Ctx.getDeclAlign(VD).alignmentAtOffset(Result.Offset); + rjmccall wrote: > Does this

[PATCH] D78767: [Sema] Teach -Wcast-align to compute a more accurate alignment when the source expression has array subscript or pointer arithmetic operators

2020-04-24 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments. Comment at: clang/include/clang/AST/Expr.h:710 + /// possible to compute the alignment, return zero. + CharUnits getAlignmentFromDecl(ASTContext ) const; + Nothing about the name here suggests that it only works on expressions

[PATCH] D78767: [Sema] Teach -Wcast-align to compute a more accurate alignment when the source expression has array subscript or pointer arithmetic operators

2020-04-23 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision. ahatanak added reviewers: arphaman, erik.pilkington, rjmccall. ahatanak added a project: clang. Herald added subscribers: ributzka, dexonsmith, jkorous. This improves upon https://reviews.llvm.org/D21099, which taught -Wcast-align to look at the aligned attribute