[all-commits] [llvm/llvm-project] ec3d8e: Handle init statements in readability-else-after-r...

Nathan James via All-commits all-commits at lists.llvm.org
Thu Jan 2 10:39:34 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: ec3d8e61b527c6312f77a4dab095ffc34e954927
      https://github.com/llvm/llvm-project/commit/ec3d8e61b527c6312f77a4dab095ffc34e954927
  Author: Nathan James <n.james93 at hotmail.co.uk>
  Date:   2020-01-02 (Thu, 02 Jan 2020)

  Changed paths:
    M clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
    M clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.h
    A clang-tools-extra/test/clang-tidy/checkers/readability-else-after-return-no-warn.cpp
    M clang-tools-extra/test/clang-tidy/checkers/readability-else-after-return.cpp
    M clang/docs/LibASTMatchersReference.html
    M clang/include/clang/ASTMatchers/ASTMatchers.h
    M clang/lib/ASTMatchers/Dynamic/Registry.cpp
    M clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

  Log Message:
  -----------
  Handle init statements in readability-else-after-return

Adds a new ASTMatcher condition called 'hasInitStatement()' that matches if,
switch and range-for statements with an initializer. Reworked clang-tidy
readability-else-after-return to handle variables in the if condition or init
statements in c++17 ifs. Also checks if removing the else would affect object
lifetimes in the else branch.

Fixes PR44364.




More information about the All-commits mailing list