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
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 =
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
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/
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:
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
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
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
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
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
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
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,
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
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/
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
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
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
17 matches
Mail list logo