Re: [PATCH] D13643: [Sema] Warn on ternary comparison

2015-11-01 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment. Mostly looks good; the only thing left is a test to ensure the fixits are placing the parens in the expected location. Comment at: lib/Sema/SemaChecking.cpp:6725 @@ -6706,1 +6724,3 @@ static void AnalyzeComparison(Sema , BinaryOperator *E) { +

Re: [PATCH] D13643: [Sema] Warn on ternary comparison

2015-10-30 Thread Matěj Grabovský via cfe-commits
mgrabovsky added a comment. Any other remarks? http://reviews.llvm.org/D13643 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Re: [PATCH] D13643: [Sema] Warn on ternary comparison

2015-10-21 Thread Matěj Grabovský via cfe-commits
mgrabovsky updated this revision to Diff 37985. mgrabovsky added a comment. Fix comparisons with implicit casts and mismatched types http://reviews.llvm.org/D13643 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaChecking.cpp test/Sema/bool-compare.c Index:

Re: [PATCH] D13643: [Sema] Warn on ternary comparison

2015-10-21 Thread Matěj Grabovský via cfe-commits
mgrabovsky added a comment. In http://reviews.llvm.org/D13643#270813, @danielmarjamaki wrote: > If you're interested.. it does not currently warn about "1.0 < 2.0 < 3.0" as > far as I see. I have now fixed this for C, but the issue remains for C++ and I have absolutely no idea what's going

Re: [PATCH] D13643: [Sema] Warn on ternary comparison

2015-10-21 Thread Matěj Grabovský via cfe-commits
mgrabovsky added a comment. In http://reviews.llvm.org/D13643#272046, @danielmarjamaki wrote: > In http://reviews.llvm.org/D13643#271885, @danielmarjamaki wrote: > > > I tested this on 2199 debian projects.. and got 16 warnings. > > > >

Re: [PATCH] D13643: [Sema] Warn on ternary comparison

2015-10-21 Thread Matěj Grabovský via cfe-commits
mgrabovsky updated this revision to Diff 37987. mgrabovsky added a comment. Correction for C++ tests http://reviews.llvm.org/D13643 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaChecking.cpp test/Sema/bool-compare.c test/SemaCXX/bool-compare.cpp Index:

Re: [PATCH] D13643: [Sema] Warn on ternary comparison

2015-10-21 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki added a comment. In http://reviews.llvm.org/D13643#271885, @danielmarjamaki wrote: > I tested this on 2199 debian projects.. and got 16 warnings. > > ftp://ftp.se.debian.org/debian/pool/main/t/tf5/tf5_5.0beta8.orig.tar.gz > expr.c:738:22: warning: comparisons such as 'a < b

Re: [PATCH] D13643: [Sema] Warn on ternary comparison

2015-10-20 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki added a subscriber: danielmarjamaki. danielmarjamaki added a comment. Interesting checker. I'll test it on some debian projects. If you're interested.. it does not currently warn about "1.0 < 2.0 < 3.0" as far as I see. http://reviews.llvm.org/D13643

Re: [PATCH] D13643: [Sema] Warn on ternary comparison

2015-10-20 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki added a comment. I tested this on 2199 debian projects.. and got 16 warnings. ftp://ftp.se.debian.org/debian/pool/main/t/tf5/tf5_5.0beta8.orig.tar.gz expr.c:738:22: warning: comparisons such as 'a < b != c' do not have their mathematical meaning [-Wparentheses] if

Re: [PATCH] D13643: [Sema] Warn on ternary comparison

2015-10-19 Thread Matěj Grabovský via cfe-commits
mgrabovsky updated this revision to Diff 37720. mgrabovsky added a comment. Change message wording http://reviews.llvm.org/D13643 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaChecking.cpp test/Sema/bool-compare.c Index: test/Sema/bool-compare.c

Re: [PATCH] D13643: [Sema] Warn on ternary comparison

2015-10-18 Thread Matěj Grabovský via cfe-commits
mgrabovsky added a comment. In http://reviews.llvm.org/D13643#266926, @aaron.ballman wrote: > I would spend some time digging into how GCC handles those cases, and use > that as a baseline that we can then improve upon. I like the fact that GCC > basically says "use parens to clarify your

Re: [PATCH] D13643: [Sema] Warn on ternary comparison

2015-10-14 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment. In http://reviews.llvm.org/D13643#266649, @mgrabovsky wrote: > In http://reviews.llvm.org/D13643#265976, @aaron.ballman wrote: > > > Should there be an exception to this diagnostic for code involving Boolean > > values? e.g., > > > > void f(bool a, bool b, bool c)

Re: [PATCH] D13643: [Sema] Warn on ternary comparison

2015-10-14 Thread Matěj Grabovský via cfe-commits
mgrabovsky added a comment. In http://reviews.llvm.org/D13643#265976, @aaron.ballman wrote: > Should there be an exception to this diagnostic for code involving Boolean > values? e.g., > > void f(bool a, bool b, bool c) { > > if (a == b == c) > ; > > } > > At the very least, it seems like

Re: [PATCH] D13643: [Sema] Warn on ternary comparison

2015-10-13 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment. Should there be an exception to this diagnostic for code involving Boolean values? e.g., void f(bool a, bool b, bool c) { if (a == b == c) ; } At the very least, it seems like this should also follow GCC's behavior and suggest parenthesis directly.

[PATCH] D13643: [Sema] Warn on ternary comparison

2015-10-12 Thread Matěj Grabovský via cfe-commits
mgrabovsky created this revision. mgrabovsky added a subscriber: cfe-commits. This change adds a Sema diagnostic for comparisons like `a < b < c`, which usually do not behave as intended by the author. Fixes bug 20082. http://reviews.llvm.org/D13643 Files: