[PATCH] D37014: [clang-tidy] Add a checker to remove useless intermediate variables before return statements with comparisons

2018-03-31 Thread Tristan Bourvon via Phabricator via cfe-commits
tbourvon updated this revision to Diff 140541. tbourvon marked 3 inline comments as done. tbourvon added a comment. Order and link fixes in the release notes https://reviews.llvm.org/D37014 Files: clang-tidy/readability/CMakeLists.txt clang-tidy/readability/ReadabilityTidyModule.cpp clang

[PATCH] D37014: [clang-tidy] Add a checker to remove useless intermediate variables before return statements with comparisons

2018-03-29 Thread Tristan Bourvon via Phabricator via cfe-commits
tbourvon marked an inline comment as done. tbourvon added inline comments. Comment at: docs/ReleaseNotes.rst:62 - New `bugprone-throw-keyword-missing `_ check Eugene.Zelenk

[PATCH] D37014: [clang-tidy] Add a checker to remove useless intermediate variables before return statements with comparisons

2018-03-29 Thread Tristan Bourvon via Phabricator via cfe-commits
tbourvon updated this revision to Diff 140278. tbourvon marked 10 inline comments as done. tbourvon added a comment. Fixed review comments https://reviews.llvm.org/D37014 Files: clang-tidy/readability/CMakeLists.txt clang-tidy/readability/ReadabilityTidyModule.cpp clang-tidy/readability/U

[PATCH] D37014: [clang-tidy] Add a checker to remove useless intermediate variables before return statements with comparisons

2018-03-12 Thread Tristan Bourvon via Phabricator via cfe-commits
tbourvon added a comment. @alexfh Do you think we can merge this? I think I've been through every suggestion and it would be nice to finally land the check! https://reviews.llvm.org/D37014 ___ cfe-commits mailing list cfe-commits@lists.llvm.org htt

[PATCH] D37014: [clang-tidy] Add a checker to remove useless intermediate variables before return statements with comparisons

2018-03-08 Thread Tristan Bourvon via Phabricator via cfe-commits
tbourvon updated this revision to Diff 137588. tbourvon added a comment. Moves the custom matcher to the check instead of having it in `utils/Matchers.h` https://reviews.llvm.org/D37014 Files: clang-tidy/readability/CMakeLists.txt clang-tidy/readability/ReadabilityTidyModule.cpp clang-tid

[PATCH] D42624: [clang-tidy] Add a utility Matcher to match the next statement within a statement sequence

2018-03-05 Thread Tristan Bourvon via Phabricator via cfe-commits
tbourvon added a comment. @alexfh What is your opinion regarding adding this dependency? Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D42624 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mail

[PATCH] D37014: [clang-tidy] Add a checker to remove useless intermediate variables before return statements with comparisons

2018-02-19 Thread Tristan Bourvon via Phabricator via cfe-commits
tbourvon updated this revision to Diff 134936. tbourvon added a comment. This updates the patch to use `clang::tooling::fixit::getText()` instead of the custom `getStmtText`. This also adds a macro unit test. https://reviews.llvm.org/D37014 Files: clang-tidy/readability/CMakeLists.txt clan

[PATCH] D42623: [clang-tidy] Add a Lexer util to get the source text of a statement

2018-02-13 Thread Tristan Bourvon via Phabricator via cfe-commits
tbourvon abandoned this revision. tbourvon added inline comments. Comment at: clang-tidy/utils/LexerUtils.h:26 +/// Get source code text for statement. +Optional getStmtText(const Stmt* Statement, const SourceManager& SM); + alexfh wrote: > aaron.ballman wrote:

[PATCH] D42624: [clang-tidy] Add a utility Matcher to match the next statement within a statement sequence

2018-02-13 Thread Tristan Bourvon via Phabricator via cfe-commits
tbourvon added inline comments. Comment at: clang-tidy/utils/Matchers.h:16 +#include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/Analysis/CFG.h" aaron.ballman wrote: > This will require linking in the clangAnalysis library as well; are we sure > we w

[PATCH] D37014: [clang-tidy] Add a checker to remove useless intermediate variables before return statements with comparisons

2018-01-28 Thread Tristan Bourvon via Phabricator via cfe-commits
tbourvon marked an inline comment as done. tbourvon added inline comments. Comment at: test/clang-tidy/readability-unnecessary-intermediate-var.cpp:206 + auto test = 1; // Test +#ifdef INTERMITTENT_MACRO + return (test == 1); lebedev.ri wrote: > Tests are nice

[PATCH] D42624: [clang-tidy] Add a utility Matcher to match the next statement within a statement sequence

2018-01-28 Thread Tristan Bourvon via Phabricator via cfe-commits
tbourvon created this revision. tbourvon added a reviewer: lebedev.ri. tbourvon added a project: clang-tools-extra. Herald added subscribers: hintonda, xazax.hun, mgorny. This adds a utility matcher (which is placed in `util/Matchers.h`, because it uses functions from `ASTMatchFinder.h` which can

[PATCH] D42623: [clang-tidy] Add a Lexer util to get the source text of a statement

2018-01-28 Thread Tristan Bourvon via Phabricator via cfe-commits
tbourvon created this revision. tbourvon added a reviewer: lebedev.ri. tbourvon added a project: clang-tools-extra. Herald added subscribers: hintonda, xazax.hun, mgorny. This is a simple Lexer util to get the source text of a statement given as parameter. This is needed for https://reviews.llvm.

[PATCH] D37014: [clang-tidy] Add a checker to remove useless intermediate variables before return statements with comparisons

2018-01-28 Thread Tristan Bourvon via Phabricator via cfe-commits
tbourvon updated this revision to Diff 131709. tbourvon added a comment. Herald added a subscriber: hintonda. Separated the added matcher and lexer utils into a different diff. Also added unit tests to make sure we behave as expected when macros get in the way of the code we detect. https://rev

[PATCH] D37014: [clang-tidy] Add a checker to remove useless intermediate variables before return statements with comparisons

2018-01-10 Thread Tristan Bourvon via Phabricator via cfe-commits
tbourvon marked 4 inline comments as done. tbourvon added a comment. (By the way, credits go to @Abpostelnicu for the latest changes regarding MaximumLineLength interop with clang-format options) Comment at: clang-tidy/readability/UnnecessaryIntermediateVarCheck.cpp:376 +/

[PATCH] D37014: [clang-tidy] Add a checker to remove useless intermediate variables before return statements with comparisons

2018-01-10 Thread Tristan Bourvon via Phabricator via cfe-commits
tbourvon updated this revision to Diff 129278. tbourvon added a comment. Add retrieval of MaximumLineLength from clang-format options, otherwise defaults to 80. Also add unit tests around the limit case for the line length. https://reviews.llvm.org/D37014 Files: clang-tidy/readability/CMakeL

[PATCH] D37014: [clang-tidy] Add a checker to remove useless intermediate variables before return statements with comparisons

2017-08-23 Thread Tristan Bourvon via Phabricator via cfe-commits
tbourvon updated this revision to Diff 112356. tbourvon marked an inline comment as done. tbourvon added a comment. Forgot to move the comments on small matchers as suggested by review. https://reviews.llvm.org/D37014 Files: clang-tidy/readability/CMakeLists.txt clang-tidy/readability/Reada

[PATCH] D37014: [clang-tidy] Add a checker to remove useless intermediate variables before return statements with comparisons

2017-08-23 Thread Tristan Bourvon via Phabricator via cfe-commits
tbourvon marked 14 inline comments as done. tbourvon added inline comments. Comment at: clang-tidy/readability/UselessIntermediateVarCheck.h:29 + : ClangTidyCheck(Name, Context), +MaximumLineLength(Options.get("MaximumLineLength", 100)) {} + void registerMatchers(as

[PATCH] D37014: [clang-tidy] Add a checker to remove useless intermediate variables before return statements with comparisons

2017-08-23 Thread Tristan Bourvon via Phabricator via cfe-commits
tbourvon updated this revision to Diff 112351. tbourvon added a comment. Fixing the reviewers' remarks, mainly formatting and const-correctness, as well as adding a few more tests. https://reviews.llvm.org/D37014 Files: clang-tidy/readability/CMakeLists.txt clang-tidy/readability/Readabili

[PATCH] D37014: [clang-tidy] Add a checker to remove useless intermediate variables before return statements with comparisons

2017-08-23 Thread Tristan Bourvon via Phabricator via cfe-commits
tbourvon added a comment. In https://reviews.llvm.org/D37014#850088, @lebedev.ri wrote: > In https://reviews.llvm.org/D37014#850064, @tbourvon wrote: > > > In https://reviews.llvm.org/D37014#849157, @lebedev.ri wrote: > > > > > Please add the following test: (and make sure that it does the right

[PATCH] D37014: [clang-tidy] Add a checker to remove useless intermediate variables before return statements with comparisons

2017-08-23 Thread Tristan Bourvon via Phabricator via cfe-commits
tbourvon added a comment. In https://reviews.llvm.org/D37014#849157, @lebedev.ri wrote: > Please add the following test: (and make sure that it does the right thing :)) > > bool f_with_preproc_condition() { > auto test = 42; > assert(test == 42); > return test; > } > > > I.e. if `

[PATCH] D37014: [clang-tidy] Add a checker to remove useless intermediate variables before return statements with comparisons

2017-08-22 Thread Tristan Bourvon via Phabricator via cfe-commits
tbourvon created this revision. Herald added subscribers: xazax.hun, JDevlieghere, mgorny. This patch adds a checker to detect patterns of the following form: auto IntermediateVar = foo(); return (IntermediateVar == 1); and suggests to turn them into: return (foo() == 1); The reasoning b

[PATCH] D37014: [clang-tidy] Add a checker to remove useless intermediate variables before return statements with comparisons

2017-08-22 Thread Tristan Bourvon via Phabricator via cfe-commits
tbourvon added a comment. Some more precisions I kept out of the revision body for clarity: The checker contains a configuration option to set the maximum line length for the fixed return statement, so that we make sure this checker always contributes to improving readability and not the contra