diff options
| author | Alexander Kornienko <alexfh@google.com> | 2017-02-06 15:46:33 +0000 |
|---|---|---|
| committer | Alexander Kornienko <alexfh@google.com> | 2017-02-06 15:46:33 +0000 |
| commit | 2d73022122de1ba8f4fbfa8a0ef855b0529cedd9 (patch) | |
| tree | 7e6effdb34ee9680d2eb60739905fd653df018c2 /clang-tools-extra/clang-tidy/utils | |
| parent | 3e582c8855b44ef6d61d863a7db8ae5189c68682 (diff) | |
| download | bcm5719-llvm-2d73022122de1ba8f4fbfa8a0ef855b0529cedd9.tar.gz bcm5719-llvm-2d73022122de1ba8f4fbfa8a0ef855b0529cedd9.zip | |
[clang-tidy] getPreviousNonCommentToken -> getPreviousToken
llvm-svn: 294192
Diffstat (limited to 'clang-tools-extra/clang-tidy/utils')
| -rw-r--r-- | clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp | 2 | ||||
| -rw-r--r-- | clang-tools-extra/clang-tidy/utils/LexerUtils.cpp | 6 | ||||
| -rw-r--r-- | clang-tools-extra/clang-tidy/utils/LexerUtils.h | 7 |
3 files changed, 7 insertions, 8 deletions
diff --git a/clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp b/clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp index d385cef2248..0627e51931e 100644 --- a/clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp +++ b/clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp @@ -18,7 +18,7 @@ namespace fixit { FixItHint changeVarDeclToReference(const VarDecl &Var, ASTContext &Context) { SourceLocation AmpLocation = Var.getLocation(); - auto Token = utils::lexer::getPreviousNonCommentToken(Context, AmpLocation); + auto Token = utils::lexer::getPreviousToken(Context, AmpLocation); if (!Token.is(tok::unknown)) AmpLocation = Lexer::getLocForEndOfToken(Token.getLocation(), 0, Context.getSourceManager(), diff --git a/clang-tools-extra/clang-tidy/utils/LexerUtils.cpp b/clang-tools-extra/clang-tidy/utils/LexerUtils.cpp index f80661d68db..d0272191300 100644 --- a/clang-tools-extra/clang-tidy/utils/LexerUtils.cpp +++ b/clang-tools-extra/clang-tidy/utils/LexerUtils.cpp @@ -14,8 +14,8 @@ namespace tidy { namespace utils { namespace lexer { -Token getPreviousNonCommentToken(const ASTContext &Context, - SourceLocation Location) { +Token getPreviousToken(const ASTContext &Context, SourceLocation Location, + bool SkipComments) { const auto &SourceManager = Context.getSourceManager(); Token Token; Token.setKind(tok::unknown); @@ -27,7 +27,7 @@ Token getPreviousNonCommentToken(const ASTContext &Context, Context.getLangOpts()); if (!Lexer::getRawToken(Location, Token, SourceManager, Context.getLangOpts()) && - !Token.is(tok::comment)) { + (!SkipComments || !Token.is(tok::comment))) { break; } Location = Location.getLocWithOffset(-1); diff --git a/clang-tools-extra/clang-tidy/utils/LexerUtils.h b/clang-tools-extra/clang-tidy/utils/LexerUtils.h index f2185927ae3..f7bcd6f63d2 100644 --- a/clang-tools-extra/clang-tidy/utils/LexerUtils.h +++ b/clang-tools-extra/clang-tidy/utils/LexerUtils.h @@ -18,10 +18,9 @@ namespace tidy { namespace utils { namespace lexer { -/// Returns previous non-comment token skipping over any comment text or -/// ``tok::unknown`` if not found. -Token getPreviousNonCommentToken(const ASTContext &Context, - SourceLocation Location); +/// Returns previous token or ``tok::unknown`` if not found. +Token getPreviousToken(const ASTContext &Context, SourceLocation Location, + bool SkipComments = true); } // namespace lexer } // namespace utils |

