[PATCH] D66045: Improve detection of same value in comparisons

2019-09-20 Thread Richard Trieu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rL372453: Merge and improve code that detects same value in comparisons. (authored by rtrieu, committed by ). Herald added a project: LLVM. Herald added a subscriber: llvm-commits. Changed prior to commit:

[PATCH] D66045: Improve detection of same value in comparisons

2019-08-16 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision. NoQ added a comment. This revision is now accepted and ready to land. Thanks from me as well. Comment at: lib/AST/Expr.cpp:4009 + auto getAnyDecl = [](const Expr *E) -> const ValueDecl * { +if (auto *DRE = dyn_cast(E)) + return

[PATCH] D66045: Improve detection of same value in comparisons

2019-08-13 Thread JF Bastien via Phabricator via cfe-commits
jfb added inline comments. Comment at: test/SemaCXX/self-comparison.cpp:87 +}; +} // namespace member_tests rtrieu wrote: > jfb wrote: > > rtrieu wrote: > > > rtrieu wrote: > > > > jfb wrote: > > > > > The test only has `==`. Do other operators trigger? > > > > A

[PATCH] D66045: Improve detection of same value in comparisons

2019-08-13 Thread Richard Trieu via Phabricator via cfe-commits
rtrieu marked an inline comment as done. rtrieu added inline comments. Comment at: test/SemaCXX/self-comparison.cpp:87 +}; +} // namespace member_tests jfb wrote: > rtrieu wrote: > > rtrieu wrote: > > > jfb wrote: > > > > The test only has `==`. Do other operator

[PATCH] D66045: Improve detection of same value in comparisons

2019-08-13 Thread Richard Trieu via Phabricator via cfe-commits
rtrieu updated this revision to Diff 215002. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D66045/new/ https://reviews.llvm.org/D66045 Files: include/clang/AST/Expr.h lib/AST/Expr.cpp lib/Analysis/CFG.cpp lib/Sema/SemaExpr.cpp test/Analysis/array-struct-region.cpp test/Sema/wa

[PATCH] D66045: Improve detection of same value in comparisons

2019-08-12 Thread JF Bastien via Phabricator via cfe-commits
jfb added inline comments. Comment at: test/SemaCXX/self-comparison.cpp:87 +}; +} // namespace member_tests rtrieu wrote: > rtrieu wrote: > > jfb wrote: > > > The test only has `==`. Do other operators trigger? > > All the standard comparison operators will work

[PATCH] D66045: Improve detection of same value in comparisons

2019-08-12 Thread Richard Trieu via Phabricator via cfe-commits
rtrieu marked 3 inline comments as done. rtrieu added inline comments. Comment at: test/Analysis/array-struct-region.cpp:31 + bool check() const { return this == this + 0; } + bool operator !() const { return this != this + 0; } NoQ wrote: > rtrieu wrote: > >

[PATCH] D66045: Improve detection of same value in comparisons

2019-08-12 Thread Richard Trieu via Phabricator via cfe-commits
rtrieu updated this revision to Diff 214752. rtrieu added a comment. Check array accesses. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D66045/new/ https://reviews.llvm.org/D66045 Files: include/clang/AST/Expr.h lib/AST/Expr.cpp lib/Analysis/CFG.cpp lib/Sema/SemaExpr.cpp test

[PATCH] D66045: Improve detection of same value in comparisons

2019-08-12 Thread Richard Trieu via Phabricator via cfe-commits
rtrieu marked 2 inline comments as done. rtrieu added inline comments. Comment at: lib/AST/Expr.cpp:3931-3932 +case DeclRefExprClass: { + // DeclRefExpr without an ImplicitCastExpr can happen for integral + // template parameters. + const auto *DRE1 = cast(E1);

[PATCH] D66045: Improve detection of same value in comparisons

2019-08-12 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments. Comment at: lib/AST/Expr.cpp:3931-3932 +case DeclRefExprClass: { + // DeclRefExpr without an ImplicitCastExpr can happen for integral + // template parameters. + const auto *DRE1 = cast(E1); Does this actually happen

[PATCH] D66045: Improve detection of same value in comparisons

2019-08-12 Thread Richard Trieu via Phabricator via cfe-commits
rtrieu marked 3 inline comments as done. rtrieu added a comment. In D66045#1624389 , @jfb wrote: > Does this work for unions as well? This will work for union accesses via the same member name, but not different member names. union U { int x; int y;

[PATCH] D66045: Improve detection of same value in comparisons

2019-08-10 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment. Does this work for unions as well? Comment at: test/Analysis/array-struct-region.cpp:31 + bool check() const { return this == this + 0; } + bool operator !() const { return this != this + 0; } Is this the only way? Or do casts also disa

[PATCH] D66045: Improve detection of same value in comparisons

2019-08-09 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a reviewer: NoQ. NoQ added a comment. I like where this is going! I'll add myself so that not to forget to review the CFG bits next week. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D66045/new/ https://reviews.llvm.org/D66045 __