[PATCH] D22507: Clang-tidy - Enum misuse check

2016-12-27 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rL290600: [clang-tidy] Add enum misuse check. (authored by xazax). Changed prior to commit: https://reviews.llvm.org/D22507?vs=82488&id=82533#toc Repository: rL LLVM https://reviews.llvm.org/D22507 F

[PATCH] D22507: Clang-tidy - Enum misuse check

2016-12-25 Thread Peter Szecsi via Phabricator via cfe-commits
szepet updated this revision to Diff 82488. szepet marked 6 inline comments as done. szepet added a comment. The requested changes have been made. Some more refactor on the Case2 since it is the same as the LHS/RHS case. Moved more common statements out of the branch (Case2-3) for better readabil

[PATCH] D22507: Clang-tidy - Enum misuse check

2016-12-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang-tidy/misc/SuspiciousEnumUsageCheck.cpp:31 +"enum type seems like a bitmask (contains mostly " +"power-of-2 literals) but some literal(s) are not a power-of-2"; + Please drop the `(s)` from the diagnos

[PATCH] D22507: Clang-tidy - Enum misuse check

2016-12-19 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment. A few more notes, all fine for a follow up. Comment at: clang-tidy/misc/SuspiciousEnumUsageCheck.cpp:202 + + const auto *LhsExpr = Result.Nodes.getNodeAs("lhsExpr"); + const auto *RhsExpr = Result.Nodes.getNodeAs("rhsExpr"); Looks like

[PATCH] D22507: Clang-tidy - Enum misuse check

2016-12-17 Thread Peter Szecsi via Phabricator via cfe-commits
szepet updated this revision to Diff 81848. szepet added a comment. Herald added a subscriber: JDevlieghere. Minor changes to improve the readability of the code according to comments. https://reviews.llvm.org/D22507 Files: clang-tidy/misc/CMakeLists.txt clang-tidy/misc/MiscTidyModule.cpp

[PATCH] D22507: Clang-tidy - Enum misuse check

2016-12-13 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments. Comment at: clang-tidy/misc/SuspiciousEnumUsageCheck.cpp:155 + +if (EnumDec->enumerator_begin() == EnumDec->enumerator_end() || +OtherEnumDec->enumerator_begin() == OtherEnumDec->enumerator_end()) szepet wrote: > alexfh w

[PATCH] D22507: Clang-tidy - Enum misuse check

2016-12-13 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment. LG with one nit. Feel free to ping earlier next time. Comment at: clang-tidy/misc/SuspiciousEnumUsageCheck.cpp:170-171 + if (const auto *EnumExpr = Result.Nodes.getNodeAs("enumExpr")) { +if (!StrictMode) + return; +const auto *EnumDec = Res

[PATCH] D22507: Clang-tidy - Enum misuse check

2016-12-13 Thread Peter Szecsi via Phabricator via cfe-commits
szepet added a comment. What is your opinion about the new results? I hope the checker can make it into 4.0. https://reviews.llvm.org/D22507 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-

[PATCH] D22507: Clang-tidy - Enum misuse check

2016-10-04 Thread Peter Szecsi via cfe-commits
szepet updated this revision to Diff 73439. szepet marked an inline comment as done. szepet added a comment. Herald added a subscriber: modocache. Note message checks added to testfiles. https://reviews.llvm.org/D22507 Files: clang-tidy/misc/CMakeLists.txt clang-tidy/misc/MiscTidyModule.cpp

[PATCH] D22507: Clang-tidy - Enum misuse check

2016-09-30 Thread Peter Szecsi via cfe-commits
szepet added inline comments. > alexfh wrote in SuspiciousEnumUsageCheck.cpp:155 > Why? Because the hasDisjointValueRange function could not decide the values properly. So in case of an empty Enum it would not make sense. Fortunately we know that the empty case should not be reported so used e

[PATCH] D22507: Clang-tidy - Enum misuse check

2016-09-30 Thread Peter Szecsi via cfe-commits
szepet updated this revision to Diff 73157. szepet marked 13 inline comments as done. szepet added a comment. Updates based on comments (the testfile note comments will be added in the next commit) Some changes in the algorithm/design: In non-strict mode the checker will only investigate the ope

Re: [PATCH] D22507: Clang-tidy - Enum misuse check

2016-09-23 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision. alexfh added a comment. This revision now requires changes to proceed. Thank you for the updates! Please re-run the check on LLVM to see what has changed. Comment at: clang-tidy/misc/SuspiciousEnumUsageCheck.cpp:53 @@ +52,3 @@ +} +stat

Re: [PATCH] D22507: Clang-tidy - Enum misuse check

2016-09-20 Thread Peter Szecsi via cfe-commits
szepet updated the summary for this revision. szepet updated this revision to Diff 71925. szepet marked 7 inline comments as done. szepet added a comment. Herald added subscribers: mgorny, beanz. In order to decrease false positive rate, the bitmask specific checker part investigate only the enum

Re: [PATCH] D22507: Clang-tidy - Enum misuse check

2016-09-07 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision. alexfh added a comment. This revision now requires changes to proceed. Close, but still a bunch of comments in the docs and a suggestion to fix a class of false positives. Comment at: clang-tidy/misc/EnumMisuseCheck.cpp:210 @@ +209,3 @

Re: [PATCH] D22507: Clang-tidy - Enum misuse check

2016-09-05 Thread Peter Szecsi via cfe-commits
szepet updated this revision to Diff 70324. szepet marked 4 inline comments as done. szepet added a comment. cast to dyn-cast change in order to fix a bug, changes based on comments https://reviews.llvm.org/D22507 Files: clang-tidy/misc/CMakeLists.txt clang-tidy/misc/EnumMisuseCheck.cpp c

Re: [PATCH] D22507: Clang-tidy - Enum misuse check

2016-09-02 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments. Comment at: test/clang-tidy/misc-enum-misuse.cpp:3 @@ +2,3 @@ + +enum Empty { +}; szepet wrote: > Could you specify which part of the file seems off? I have run the clang > format with the same options on testfiles as on the o

Re: [PATCH] D22507: Clang-tidy - Enum misuse check

2016-09-01 Thread Peter Szecsi via cfe-commits
szepet added inline comments. Comment at: test/clang-tidy/misc-enum-misuse.cpp:3 @@ +2,3 @@ + +enum Empty { +}; Could you specify which part of the file seems off? I have run the clang format with the same options on testfiles as on the others. https://reviews.

Re: [PATCH] D22507: Clang-tidy - Enum misuse check

2016-09-01 Thread Peter Szecsi via cfe-commits
szepet updated this revision to Diff 70017. szepet marked 11 inline comments as done. szepet added a comment. Changes based on comments, fix a cast to dyn_cast bug, description updated (hopefully it became more clear). https://reviews.llvm.org/D22507 Files: clang-tidy/misc/CMakeLists.txt c

Re: [PATCH] D22507: Clang-tidy - Enum misuse check

2016-08-24 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision. This revision now requires changes to proceed. Comment at: clang-tidy/misc/EnumMisuseCheck.cpp:215 @@ +214,3 @@ +"number(s)"); + diag(RhsExpr->getExprLoc(), "Used here as a bitmask.", +

Re: [PATCH] D22507: Clang-tidy - Enum misuse check

2016-08-23 Thread Peter Szecsi via cfe-commits
szepet added inline comments. Comment at: clang-tidy/misc/EnumMisuseCheck.cpp:75 @@ +74,3 @@ +// We check if there is at most 2 not power-of-2 value in the enum type and +// the +// it contains enough element to make sure it could be a biftield, but we aaron.ballm

Re: [PATCH] D22507: Clang-tidy - Enum misuse check

2016-08-23 Thread Peter Szecsi via cfe-commits
szepet updated this revision to Diff 68968. szepet marked 18 inline comments as done. szepet added a comment. Changes based on comments. https://reviews.llvm.org/D22507 Files: clang-tidy/misc/CMakeLists.txt clang-tidy/misc/EnumMisuseCheck.cpp clang-tidy/misc/EnumMisuseCheck.h clang-tidy

Re: [PATCH] D22507: Clang-tidy - Enum misuse check

2016-08-17 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision. This revision now requires changes to proceed. Comment at: clang-tidy/misc/EnumMisuseCheck.cpp:28 @@ +27,3 @@ +llvm::APSInt BeginVal = EnumDec->enumerator_begin()->getInitVal(); +{ + const auto MinMaxVal = std::minmax_element

Re: [PATCH] D22507: Clang-tidy - Enum misuse check

2016-07-29 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments. Comment at: clang-tidy/misc/EnumMisuseCheck.cpp:40 @@ +39,3 @@ + +// Return the number of EnumConstantDecls in an EnumDecl. +static int enumLength(const EnumDecl *EnumDec) { Doxygen comment here as well. Comme

Re: [PATCH] D22507: Clang-tidy - Enum misuse check

2016-07-28 Thread Peter Szecsi via cfe-commits
szepet marked 2 inline comments as done. szepet added a comment. https://reviews.llvm.org/D22507 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Re: [PATCH] D22507: Clang-tidy - Enum misuse check

2016-07-28 Thread Peter Szecsi via cfe-commits
szepet updated this revision to Diff 65966. szepet marked 12 inline comments as done. szepet added a comment. updates based on comments, counter and search functions replaced by std functions https://reviews.llvm.org/D22507 Files: clang-tidy/misc/CMakeLists.txt clang-tidy/misc/EnumMisuseCh

Re: [PATCH] D22507: Clang-tidy - Enum misuse check

2016-07-25 Thread Piotr Padlewski via cfe-commits
Prazek added a subscriber: Prazek. Comment at: clang-tidy/misc/EnumMisuseCheck.cpp:19 @@ +18,3 @@ + +// Stores a min and a max value which describe an interval. +struct ValueRange { s/\/\//\/\/\/ In other words, change // to /// (doxygen comment) ===

Re: [PATCH] D22507: Clang-tidy - Enum misuse check

2016-07-25 Thread Etienne Bergeron via cfe-commits
etienneb added a comment. some nits Comment at: docs/clang-tidy/checks/misc-enum-misuse.rst:37 @@ +36,3 @@ +unsigned flag; +flag = A | H; //OK, disjoint value intervalls in the enum types > probably good use +flag = B | F; //warning, have common values so they are probably misu

Re: [PATCH] D22507: Clang-tidy - Enum misuse check

2016-07-25 Thread Peter Szecsi via cfe-commits
szepet updated this revision to Diff 65310. szepet added a comment. full diff submitted https://reviews.llvm.org/D22507 Files: clang-tidy/misc/CMakeLists.txt clang-tidy/misc/EnumMisuseCheck.cpp clang-tidy/misc/EnumMisuseCheck.h clang-tidy/misc/MiscTidyModule.cpp docs/clang-tidy/checks

Re: [PATCH] D22507: Clang-tidy - Enum misuse check

2016-07-22 Thread Haojian Wu via cfe-commits
hokein added a comment. Seems that you only uploaded the diff part, I only see the updated part of your patch now, and can't see the whole patch now (The review page says "Context not available"), could you upload the whole patch again? Comment at: docs/clang-tidy/checks/misc

Re: [PATCH] D22507: Clang-tidy - Enum misuse check

2016-07-21 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman. Comment at: clang-tidy/misc/EnumMisuseCheck.cpp:31 @@ +30,3 @@ +// Stores a min and a max value which describe an interval. +struct ValueRange { + llvm::APSInt MinVal, MaxVal; I think this class can be replaced by

Re: [PATCH] D22507: Clang-tidy - Enum misuse check

2016-07-21 Thread Peter Szecsi via cfe-commits
szepet marked an inline comment as done. szepet added a comment. https://reviews.llvm.org/D22507 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Re: [PATCH] D22507: Clang-tidy - Enum misuse check

2016-07-21 Thread Peter Szecsi via cfe-commits
szepet removed rL LLVM as the repository for this revision. szepet updated this revision to Diff 64897. szepet added a comment. updating patch based on review comments https://reviews.llvm.org/D22507 Files: clang-tidy/misc/EnumMisuseCheck.cpp clang-tidy/misc/EnumMisuseCheck.h docs/clang-t

Re: [PATCH] D22507: Clang-tidy - Enum misuse check

2016-07-21 Thread Peter Szecsi via cfe-commits
szepet marked 18 inline comments as done. szepet added a comment. https://reviews.llvm.org/D22507 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Re: [PATCH] D22507: Clang-tidy - Enum misuse check

2016-07-19 Thread Etienne Bergeron via cfe-commits
etienneb added a comment. drive-by, some comments. Thanks for the check Comment at: clang-tidy/misc/EnumMisuseCheck.cpp:20 @@ +19,3 @@ +// Return the number of EnumConstantDecls in an EnumDecl. +static int enumLen(const EnumDecl *EnumDec) { + int Counter = 0; h

Re: [PATCH] D22507: Clang-tidy - Enum misuse check

2016-07-19 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko. Eugene.Zelenko added a comment. Please mention this check in docs/ReleaseNotes.rst. See pre-4.0 branch versions as example. Comment at: clang-tidy/misc/EnumMisuseCheck.cpp:116 @@ +115,3 @@ +} +// if there is only one not power-