diff options
| author | Mads Ravn <madsravn@gmail.com> | 2019-05-26 17:00:38 +0000 |
|---|---|---|
| committer | Mads Ravn <madsravn@gmail.com> | 2019-05-26 17:00:38 +0000 |
| commit | bd324fa2273778430a4fdf8371fec5d64d2231bb (patch) | |
| tree | 63889f0e6bc523087ba92179fff2f8e13f3c8edb /clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.cpp | |
| parent | a044410f37e9fbef56370bb4fab64b60e13b4ca2 (diff) | |
| download | bcm5719-llvm-bd324fa2273778430a4fdf8371fec5d64d2231bb.tar.gz bcm5719-llvm-bd324fa2273778430a4fdf8371fec5d64d2231bb.zip | |
DeleteNullPointerCheck now deletes until the end brace of the condition.
Patch by Jonathan Camilleri
Differential Revision https://reviews.llvm.org/D61861
llvm-svn: 361735
Diffstat (limited to 'clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.cpp')
| -rw-r--r-- | clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.cpp b/clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.cpp index 0c5eacef2e5..303833d73ec 100644 --- a/clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "DeleteNullPointerCheck.h" +#include "../utils/LexerUtils.h" #include "clang/AST/ASTContext.h" #include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/Lex/Lexer.h" @@ -62,9 +63,11 @@ void DeleteNullPointerCheck::check(const MatchFinder::MatchResult &Result) { Diag << FixItHint::CreateRemoval(CharSourceRange::getTokenRange( IfWithDelete->getBeginLoc(), - Lexer::getLocForEndOfToken(IfWithDelete->getCond()->getEndLoc(), 0, - *Result.SourceManager, - Result.Context->getLangOpts()))); + utils::lexer::getPreviousToken(IfWithDelete->getThen()->getBeginLoc(), + *Result.SourceManager, + Result.Context->getLangOpts()) + .getLocation())); + if (Compound) { Diag << FixItHint::CreateRemoval( CharSourceRange::getTokenRange(Compound->getLBracLoc())); |

