Author: omtcyfz Date: Fri Sep 16 05:12:08 2016 New Revision: 281713 URL: http://llvm.org/viewvc/llvm-project?rev=281713&view=rev Log: [clang-tidy] Bugfix for readability-redundant-control-flow check
This check did not create FixItHints when the statement before the redundant control flow was not followed by a semicolon. Patch by Malcolm Parsons! Reviewers: alexfh Differential Revision: https://reviews.llvm.org/D24500 Modified: clang-tools-extra/trunk/clang-tidy/readability/RedundantControlFlowCheck.cpp clang-tools-extra/trunk/test/clang-tidy/readability-redundant-control-flow.cpp Modified: clang-tools-extra/trunk/clang-tidy/readability/RedundantControlFlowCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/RedundantControlFlowCheck.cpp?rev=281713&r1=281712&r2=281713&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/readability/RedundantControlFlowCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/readability/RedundantControlFlowCheck.cpp Fri Sep 16 05:12:08 2016 @@ -83,7 +83,7 @@ void RedundantControlFlowCheck::issueDia dyn_cast<Stmt>(*Previous)->getLocEnd(), tok::semi, SM, Result.Context->getLangOpts(), /*SkipTrailingWhitespaceAndNewLine=*/true); - else + if (!Start.isValid()) Start = StmtRange.getBegin(); auto RemovedRange = CharSourceRange::getCharRange( Start, Modified: clang-tools-extra/trunk/test/clang-tidy/readability-redundant-control-flow.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-redundant-control-flow.cpp?rev=281713&r1=281712&r2=281713&view=diff ============================================================================== --- clang-tools-extra/trunk/test/clang-tidy/readability-redundant-control-flow.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/readability-redundant-control-flow.cpp Fri Sep 16 05:12:08 2016 @@ -179,6 +179,7 @@ void template_return(T check) { // CHECK-FIXES: {{^}} if (check < T(0)) {{{$}} // CHECK-FIXES-NEXT: {{^ return;$}} // CHECK-FIXES-NEXT: {{^ *}$}} +// CHECK-FIXES-NEXT: {{^ *}$}} template <> void template_return(int check) { @@ -191,6 +192,7 @@ void template_return(int check) { // CHECK-FIXES: {{^}} if (check < 0) {{{$}} // CHECK-FIXES-NEXT: {{^ return;$}} // CHECK-FIXES-NEXT: {{^ *}$}} +// CHECK-FIXES-NEXT: {{^ *}$}} template <typename T> void template_loop(T end) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits