summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
diff options
context:
space:
mode:
authorEtienne Bergeron <etienneb@google.com>2016-05-11 17:38:22 +0000
committerEtienne Bergeron <etienneb@google.com>2016-05-11 17:38:22 +0000
commit8311c446fc7eedb9b7e0a39251420ee876f77113 (patch)
treefe63fcf1417add1de36d3d92b8f6e149ea898781 /clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
parent3016d9e9e16729b92692c1926c7a4f4a4365628a (diff)
downloadbcm5719-llvm-8311c446fc7eedb9b7e0a39251420ee876f77113.tar.gz
bcm5719-llvm-8311c446fc7eedb9b7e0a39251420ee876f77113.zip
[clang-tidy] Refactoring of FixHintUtils
Summary: Refactor some checkers to use the tooling re-writing API. see: http://reviews.llvm.org/D19941 Reviewers: klimek, alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D19807 llvm-svn: 269210
Diffstat (limited to 'clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp b/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
index 08ea207d017..9560f1261af 100644
--- a/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
@@ -10,6 +10,7 @@
#include "ElseAfterReturnCheck.h"
#include "clang/AST/ASTContext.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Tooling/FixIt.h"
using namespace clang::ast_matchers;
@@ -28,20 +29,17 @@ void ElseAfterReturnCheck::registerMatchers(MatchFinder *Finder) {
this);
}
-static FixItHint removeToken(SourceLocation Loc) {
- return FixItHint::CreateRemoval(CharSourceRange::getTokenRange(Loc, Loc));
-}
-
void ElseAfterReturnCheck::check(const MatchFinder::MatchResult &Result) {
const auto *If = Result.Nodes.getNodeAs<IfStmt>("if");
SourceLocation ElseLoc = If->getElseLoc();
DiagnosticBuilder Diag = diag(ElseLoc, "don't use else after return");
- Diag << removeToken(ElseLoc);
+ Diag << tooling::fixit::createRemoval(ElseLoc);
// FIXME: Removing the braces isn't always safe. Do a more careful analysis.
// FIXME: Change clang-format to correctly un-indent the code.
if (const auto *CS = Result.Nodes.getNodeAs<CompoundStmt>("else"))
- Diag << removeToken(CS->getLBracLoc()) << removeToken(CS->getRBracLoc());
+ Diag << tooling::fixit::createRemoval(CS->getLBracLoc())
+ << tooling::fixit::createRemoval(CS->getRBracLoc());
}
} // namespace readability
OpenPOWER on IntegriCloud