aboutsummaryrefslogtreecommitdiff
path: root/clang-tidy/utils
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2017-02-06 15:46:33 +0000
committerAlexander Kornienko <alexfh@google.com>2017-02-06 15:46:33 +0000
commit6d0c72a1956b30d7ff3fc97a84ac35eca44b2121 (patch)
tree0b66242a55a554374acc742aef7d5d013a34bbd2 /clang-tidy/utils
parentecfd84e8cd8d25324f06af0f2d037b2d83c93c84 (diff)
[clang-tidy] getPreviousNonCommentToken -> getPreviousToken
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@294192 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clang-tidy/utils')
-rw-r--r--clang-tidy/utils/FixItHintUtils.cpp2
-rw-r--r--clang-tidy/utils/LexerUtils.cpp6
-rw-r--r--clang-tidy/utils/LexerUtils.h7
3 files changed, 7 insertions, 8 deletions
diff --git a/clang-tidy/utils/FixItHintUtils.cpp b/clang-tidy/utils/FixItHintUtils.cpp
index d385cef2..0627e519 100644
--- a/clang-tidy/utils/FixItHintUtils.cpp
+++ b/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-tidy/utils/LexerUtils.cpp b/clang-tidy/utils/LexerUtils.cpp
index f80661d6..d0272191 100644
--- a/clang-tidy/utils/LexerUtils.cpp
+++ b/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-tidy/utils/LexerUtils.h b/clang-tidy/utils/LexerUtils.h
index f2185927..f7bcd6f6 100644
--- a/clang-tidy/utils/LexerUtils.h
+++ b/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