diff options
author | Kirill Bobyrev <omtcyfz@gmail.com> | 2016-09-16 10:12:08 +0000 |
---|---|---|
committer | Kirill Bobyrev <omtcyfz@gmail.com> | 2016-09-16 10:12:08 +0000 |
commit | d7f2a35cac9bded28180dab6394b052983d23dab (patch) | |
tree | 0387eaec77d9390565af671581b0ab951e0719bd | |
parent | f9b141d16d5beb1638ccb75445cca7b6c611387e (diff) | |
download | bcm5719-llvm-d7f2a35cac9bded28180dab6394b052983d23dab.tar.gz bcm5719-llvm-d7f2a35cac9bded28180dab6394b052983d23dab.zip |
[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
llvm-svn: 281713
-rw-r--r-- | clang-tools-extra/clang-tidy/readability/RedundantControlFlowCheck.cpp | 2 | ||||
-rw-r--r-- | clang-tools-extra/test/clang-tidy/readability-redundant-control-flow.cpp | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/clang-tools-extra/clang-tidy/readability/RedundantControlFlowCheck.cpp b/clang-tools-extra/clang-tidy/readability/RedundantControlFlowCheck.cpp index 54a26e24abb..22f1111025c 100644 --- a/clang-tools-extra/clang-tidy/readability/RedundantControlFlowCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/RedundantControlFlowCheck.cpp @@ -83,7 +83,7 @@ void RedundantControlFlowCheck::issueDiagnostic( 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, diff --git a/clang-tools-extra/test/clang-tidy/readability-redundant-control-flow.cpp b/clang-tools-extra/test/clang-tidy/readability-redundant-control-flow.cpp index 09dec6f6b8e..0352e3a9444 100644 --- a/clang-tools-extra/test/clang-tidy/readability-redundant-control-flow.cpp +++ b/clang-tools-extra/test/clang-tidy/readability-redundant-control-flow.cpp @@ -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) { |