Index: clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.cpp =================================================================== --- clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.cpp @@ -91,8 +91,9 @@ getCommentsBeforeLoc(ASTContext *Ctx, SourceLocation Loc) { std::vector> Comments; while (Loc.isValid()) { - clang::Token Tok = - utils::lexer::getPreviousToken(*Ctx, Loc, /*SkipComments=*/false); + clang::Token Tok = utils::lexer::getPreviousToken( + Loc, Ctx->getSourceManager(), Ctx->getLangOpts(), + /*SkipComments=*/false); if (Tok.isNot(tok::comment)) break; Loc = Tok.getLocation(); Index: clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp =================================================================== --- clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp @@ -40,7 +40,8 @@ return; ASTContext &Ctxt = *Result.Context; - auto Token = utils::lexer::getPreviousToken(Ctxt, LocStart); + auto Token = utils::lexer::getPreviousToken(LocStart, Ctxt.getSourceManager(), + Ctxt.getLangOpts()); auto &SM = *Result.SourceManager; unsigned SemicolonLine = SM.getSpellingLineNumber(LocStart); Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp =================================================================== --- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp @@ -120,12 +120,14 @@ switch (Placement) { case InitializerPlacement::New: Location = utils::lexer::getPreviousToken( - Context, Constructor.getBody()->getBeginLoc()) + Constructor.getBody()->getBeginLoc(), + Context.getSourceManager(), Context.getLangOpts()) .getLocation(); break; case InitializerPlacement::Before: Location = utils::lexer::getPreviousToken( - Context, Where->getSourceRange().getBegin()) + Where->getSourceRange().getBegin(), + Context.getSourceManager(), Context.getLangOpts()) .getLocation(); break; case InitializerPlacement::After: Index: clang-tools-extra/trunk/clang-tidy/utils/FixItHintUtils.cpp =================================================================== --- clang-tools-extra/trunk/clang-tidy/utils/FixItHintUtils.cpp +++ clang-tools-extra/trunk/clang-tidy/utils/FixItHintUtils.cpp @@ -18,7 +18,8 @@ FixItHint changeVarDeclToReference(const VarDecl &Var, ASTContext &Context) { SourceLocation AmpLocation = Var.getLocation(); - auto Token = utils::lexer::getPreviousToken(Context, AmpLocation); + auto Token = utils::lexer::getPreviousToken( + AmpLocation, Context.getSourceManager(), Context.getLangOpts()); if (!Token.is(tok::unknown)) AmpLocation = Lexer::getLocForEndOfToken(Token.getLocation(), 0, Context.getSourceManager(), Index: clang-tools-extra/trunk/clang-tidy/utils/LexerUtils.h =================================================================== --- clang-tools-extra/trunk/clang-tidy/utils/LexerUtils.h +++ clang-tools-extra/trunk/clang-tidy/utils/LexerUtils.h @@ -19,8 +19,8 @@ namespace lexer { /// Returns previous token or ``tok::unknown`` if not found. -Token getPreviousToken(const ASTContext &Context, SourceLocation Location, - bool SkipComments = true); +Token getPreviousToken(SourceLocation Location, const SourceManager &SM, + const LangOptions &LangOpts, bool SkipComments = true); } // namespace lexer } // namespace utils Index: clang-tools-extra/trunk/clang-tidy/utils/LexerUtils.cpp =================================================================== --- clang-tools-extra/trunk/clang-tidy/utils/LexerUtils.cpp +++ clang-tools-extra/trunk/clang-tidy/utils/LexerUtils.cpp @@ -14,19 +14,15 @@ namespace utils { namespace lexer { -Token getPreviousToken(const ASTContext &Context, SourceLocation Location, - bool SkipComments) { - const auto &SourceManager = Context.getSourceManager(); +Token getPreviousToken(SourceLocation Location, const SourceManager &SM, + const LangOptions &LangOpts, bool SkipComments) { Token Token; Token.setKind(tok::unknown); Location = Location.getLocWithOffset(-1); - auto StartOfFile = - SourceManager.getLocForStartOfFile(SourceManager.getFileID(Location)); + auto StartOfFile = SM.getLocForStartOfFile(SM.getFileID(Location)); while (Location != StartOfFile) { - Location = Lexer::GetBeginningOfToken(Location, SourceManager, - Context.getLangOpts()); - if (!Lexer::getRawToken(Location, Token, SourceManager, - Context.getLangOpts()) && + Location = Lexer::GetBeginningOfToken(Location, SM, LangOpts); + if (!Lexer::getRawToken(Location, Token, SM, LangOpts) && (!SkipComments || !Token.is(tok::comment))) { break; }