diff options
28 files changed, 67 insertions, 81 deletions
diff --git a/clang-tools-extra/clang-tidy/cert/StrToNumCheck.cpp b/clang-tools-extra/clang-tidy/cert/StrToNumCheck.cpp index 765513b1f8e..d698a768d2d 100644 --- a/clang-tools-extra/clang-tidy/cert/StrToNumCheck.cpp +++ b/clang-tools-extra/clang-tidy/cert/StrToNumCheck.cpp @@ -214,7 +214,7 @@ void StrToNumCheck::check(const MatchFinder::MatchResult &Result) { // Formatted input functions need further checking of the format string to // determine whether a problematic conversion may be happening. - Conversion = ClassifyFormatString(FmtStr, Result.Context->getLangOpts(), + Conversion = ClassifyFormatString(FmtStr, getLangOpts(), Result.Context->getTargetInfo()); if (Conversion != ConversionKind::None) FuncDecl = FFD; diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp index 4055423ebc8..52156ad2221 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp @@ -68,7 +68,7 @@ void ProTypeCstyleCastCheck::check(const MatchFinder::MatchResult &Result) { CharSourceRange::getTokenRange( MatchedCast->getLParenLoc().getLocWithOffset(1), MatchedCast->getRParenLoc().getLocWithOffset(-1)), - *Result.SourceManager, Result.Context->getLangOpts()); + *Result.SourceManager, getLangOpts()); auto diag_builder = diag( MatchedCast->getLocStart(), @@ -82,8 +82,7 @@ void ProTypeCstyleCastCheck::check(const MatchFinder::MatchResult &Result) { CastText.push_back('('); diag_builder << FixItHint::CreateInsertion( Lexer::getLocForEndOfToken(SubExpr->getLocEnd(), 0, - *Result.SourceManager, - Result.Context->getLangOpts()), + *Result.SourceManager, getLangOpts()), ")"); } auto ParenRange = CharSourceRange::getTokenRange( diff --git a/clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp b/clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp index 34353b35a18..d118db58b4f 100644 --- a/clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp +++ b/clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp @@ -85,9 +85,8 @@ void AvoidCStyleCastsCheck::check(const MatchFinder::MatchResult &Result) { return; } - // The rest of this check is only relevant to C++. - if (!Result.Context->getLangOpts().CPlusPlus) + if (!getLangOpts().CPlusPlus) return; // Ignore code inside extern "C" {} blocks. if (!match(expr(hasAncestor(linkageSpecDecl())), *CastExpr, *Result.Context) @@ -109,7 +108,7 @@ void AvoidCStyleCastsCheck::check(const MatchFinder::MatchResult &Result) { Lexer::getSourceText(CharSourceRange::getTokenRange( CastExpr->getLParenLoc().getLocWithOffset(1), CastExpr->getRParenLoc().getLocWithOffset(-1)), - SM, Result.Context->getLangOpts()); + SM, getLangOpts()); auto diag_builder = diag(CastExpr->getLocStart(), "C-style casts are discouraged; use %0"); @@ -123,7 +122,7 @@ void AvoidCStyleCastsCheck::check(const MatchFinder::MatchResult &Result) { CastText.push_back('('); diag_builder << FixItHint::CreateInsertion( Lexer::getLocForEndOfToken(SubExpr->getLocEnd(), 0, SM, - Result.Context->getLangOpts()), + getLangOpts()), ")"); } diag_builder << FixItHint::CreateReplacement(ParenRange, CastText); diff --git a/clang-tools-extra/clang-tidy/google/ExplicitConstructorCheck.cpp b/clang-tools-extra/clang-tidy/google/ExplicitConstructorCheck.cpp index 0714516edf5..e79001793c4 100644 --- a/clang-tools-extra/clang-tidy/google/ExplicitConstructorCheck.cpp +++ b/clang-tools-extra/clang-tidy/google/ExplicitConstructorCheck.cpp @@ -92,7 +92,7 @@ void ExplicitConstructorCheck::check(const MatchFinder::MatchResult &Result) { Tok.getRawIdentifier() == "explicit"; }; SourceRange ExplicitTokenRange = - FindToken(*Result.SourceManager, Result.Context->getLangOpts(), + FindToken(*Result.SourceManager, getLangOpts(), Ctor->getOuterLocStart(), Ctor->getLocEnd(), isKWExplicit); StringRef ConstructorDescription; if (Ctor->isMoveConstructor()) diff --git a/clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp b/clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp index 2f39f46e63f..64444dbd307 100644 --- a/clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp +++ b/clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp @@ -45,8 +45,7 @@ void TwineLocalCheck::check(const MatchFinder::MatchResult &Result) { if (VD->getType()->getCanonicalTypeUnqualified() == C->getType()->getCanonicalTypeUnqualified()) { SourceLocation EndLoc = Lexer::getLocForEndOfToken( - VD->getInit()->getLocEnd(), 0, *Result.SourceManager, - Result.Context->getLangOpts()); + VD->getInit()->getLocEnd(), 0, *Result.SourceManager, getLangOpts()); Diag << FixItHint::CreateReplacement(TypeRange, "std::string") << FixItHint::CreateInsertion(VD->getInit()->getLocStart(), "(") << FixItHint::CreateInsertion(EndLoc, ").str()"); diff --git a/clang-tools-extra/clang-tidy/misc/AssertSideEffectCheck.cpp b/clang-tools-extra/clang-tidy/misc/AssertSideEffectCheck.cpp index 7bfbd3bcd59..0b63c0d33a4 100644 --- a/clang-tools-extra/clang-tidy/misc/AssertSideEffectCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/AssertSideEffectCheck.cpp @@ -101,7 +101,7 @@ void AssertSideEffectCheck::registerMatchers(MatchFinder *Finder) { void AssertSideEffectCheck::check(const MatchFinder::MatchResult &Result) { const SourceManager &SM = *Result.SourceManager; - const LangOptions LangOpts = Result.Context->getLangOpts(); + const LangOptions LangOpts = getLangOpts(); SourceLocation Loc = Result.Nodes.getNodeAs<Stmt>("condStmt")->getLocStart(); StringRef AssertMacroName; diff --git a/clang-tools-extra/clang-tidy/misc/InaccurateEraseCheck.cpp b/clang-tools-extra/clang-tidy/misc/InaccurateEraseCheck.cpp index 7c8a132e5e5..8b0f8fd0002 100644 --- a/clang-tools-extra/clang-tidy/misc/InaccurateEraseCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/InaccurateEraseCheck.cpp @@ -57,10 +57,9 @@ void InaccurateEraseCheck::check(const MatchFinder::MatchResult &Result) { const auto *AlgCall = Result.Nodes.getNodeAs<CallExpr>("InaccAlgCall"); std::string ReplacementText = Lexer::getSourceText( CharSourceRange::getTokenRange(EndExpr->getSourceRange()), - *Result.SourceManager, Result.Context->getLangOpts()); + *Result.SourceManager, getLangOpts()); const SourceLocation EndLoc = Lexer::getLocForEndOfToken( - AlgCall->getLocEnd(), 0, *Result.SourceManager, - Result.Context->getLangOpts()); + AlgCall->getLocEnd(), 0, *Result.SourceManager, getLangOpts()); Hint = FixItHint::CreateInsertion(EndLoc, ", " + ReplacementText); } diff --git a/clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.cpp b/clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.cpp index 810118608da..a5a5b2b4ff8 100644 --- a/clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.cpp @@ -117,7 +117,7 @@ void InefficientAlgorithmCheck::check(const MatchFinder::MatchResult &Result) { FixItHint Hint; SourceManager &SM = *Result.SourceManager; - LangOptions LangOpts = Result.Context->getLangOpts(); + LangOptions LangOpts = getLangOpts(); CharSourceRange CallRange = CharSourceRange::getTokenRange(AlgCall->getSourceRange()); diff --git a/clang-tools-extra/clang-tidy/misc/StringIntegerAssignmentCheck.cpp b/clang-tools-extra/clang-tidy/misc/StringIntegerAssignmentCheck.cpp index 69166860345..4e8c488d0c9 100644 --- a/clang-tools-extra/clang-tidy/misc/StringIntegerAssignmentCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/StringIntegerAssignmentCheck.cpp @@ -62,8 +62,7 @@ void StringIntegerAssignmentCheck::check( } SourceLocation EndLoc = Lexer::getLocForEndOfToken( - Argument->getLocEnd(), 0, *Result.SourceManager, - Result.Context->getLangOpts()); + Argument->getLocEnd(), 0, *Result.SourceManager, getLangOpts()); if (IsOneDigit) { Diag << FixItHint::CreateInsertion(Loc, IsWideCharType ? "L'" : "'") << FixItHint::CreateInsertion(EndLoc, "'"); diff --git a/clang-tools-extra/clang-tidy/misc/SuspiciousStringCompareCheck.cpp b/clang-tools-extra/clang-tidy/misc/SuspiciousStringCompareCheck.cpp index 9315ff5fb2f..7e01e6479b8 100644 --- a/clang-tools-extra/clang-tidy/misc/SuspiciousStringCompareCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/SuspiciousStringCompareCheck.cpp @@ -177,7 +177,7 @@ void SuspiciousStringCompareCheck::check( if (Result.Nodes.getNodeAs<Stmt>("missing-comparison")) { SourceLocation EndLoc = Lexer::getLocForEndOfToken( Call->getRParenLoc(), 0, Result.Context->getSourceManager(), - Result.Context->getLangOpts()); + getLangOpts()); diag(Call->getLocStart(), "function %0 is called without explicitly comparing result") @@ -187,7 +187,7 @@ void SuspiciousStringCompareCheck::check( if (const auto *E = Result.Nodes.getNodeAs<Expr>("logical-not-comparison")) { SourceLocation EndLoc = Lexer::getLocForEndOfToken( Call->getRParenLoc(), 0, Result.Context->getSourceManager(), - Result.Context->getLangOpts()); + getLangOpts()); SourceLocation NotLoc = E->getLocStart(); diag(Call->getLocStart(), diff --git a/clang-tools-extra/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp b/clang-tools-extra/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp index 9d500697f1a..78dba5a9f99 100644 --- a/clang-tools-extra/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp @@ -107,10 +107,10 @@ void UniqueptrResetReleaseCheck::check(const MatchFinder::MatchResult &Result) { std::string LeftText = clang::Lexer::getSourceText( CharSourceRange::getTokenRange(Left->getSourceRange()), - *Result.SourceManager, Result.Context->getLangOpts()); + *Result.SourceManager, getLangOpts()); std::string RightText = clang::Lexer::getSourceText( CharSourceRange::getTokenRange(Right->getSourceRange()), - *Result.SourceManager, Result.Context->getLangOpts()); + *Result.SourceManager, getLangOpts()); if (ResetMember->isArrow()) LeftText = "*" + LeftText; diff --git a/clang-tools-extra/clang-tidy/misc/UnusedAliasDeclsCheck.cpp b/clang-tools-extra/clang-tidy/misc/UnusedAliasDeclsCheck.cpp index fb18059b90c..07165d65d72 100644 --- a/clang-tools-extra/clang-tidy/misc/UnusedAliasDeclsCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/UnusedAliasDeclsCheck.cpp @@ -37,7 +37,7 @@ void UnusedAliasDeclsCheck::check(const MatchFinder::MatchResult &Result) { AliasDecl->getLocStart(), Lexer::findLocationAfterToken( AliasDecl->getLocEnd(), tok::semi, *Result.SourceManager, - Result.Context->getLangOpts(), + getLangOpts(), /*SkipTrailingWhitespaceAndNewLine=*/true)); return; } diff --git a/clang-tools-extra/clang-tidy/misc/UnusedRAIICheck.cpp b/clang-tools-extra/clang-tidy/misc/UnusedRAIICheck.cpp index 1786627d127..8350d533df7 100644 --- a/clang-tools-extra/clang-tidy/misc/UnusedRAIICheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/UnusedRAIICheck.cpp @@ -85,7 +85,7 @@ void UnusedRAIICheck::check(const MatchFinder::MatchResult &Result) { const auto *TL = selectFirst<TypeLoc>("t", Matches); D << FixItHint::CreateInsertion( Lexer::getLocForEndOfToken(TL->getLocEnd(), 0, *Result.SourceManager, - Result.Context->getLangOpts()), + getLangOpts()), Replacement); } diff --git a/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp b/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp index 3e4bb397dfc..8e4ed5a4a11 100644 --- a/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp @@ -64,8 +64,7 @@ void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) { Context.UsingDeclRange = CharSourceRange::getCharRange( Using->getLocStart(), Lexer::findLocationAfterToken( - Using->getLocEnd(), tok::semi, *Result.SourceManager, - Result.Context->getLangOpts(), + Using->getLocEnd(), tok::semi, *Result.SourceManager, getLangOpts(), /*SkipTrailingWhitespaceAndNewLine=*/true)); for (const auto *UsingShadow : Using->shadows()) { const auto *TargetDecl = UsingShadow->getTargetDecl()->getCanonicalDecl(); diff --git a/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp b/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp index 6161d6dfc94..41251610efb 100644 --- a/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp @@ -200,11 +200,10 @@ void PassByValueCheck::check(const MatchFinder::MatchResult &Result) { TypeLoc ValueTL = RefTL.getPointeeLoc(); auto TypeRange = CharSourceRange::getTokenRange(ParmDecl->getLocStart(), ParamTL.getLocEnd()); - std::string ValueStr = - Lexer::getSourceText( - CharSourceRange::getTokenRange(ValueTL.getSourceRange()), SM, - Result.Context->getLangOpts()) - .str(); + std::string ValueStr = Lexer::getSourceText(CharSourceRange::getTokenRange( + ValueTL.getSourceRange()), + SM, getLangOpts()) + .str(); ValueStr += ' '; Diag << FixItHint::CreateReplacement(TypeRange, ValueStr); } diff --git a/clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp b/clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp index 1f51caa0f61..8d893ad3560 100644 --- a/clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp @@ -108,15 +108,15 @@ void RawStringLiteralCheck::storeOptions(ClangTidyOptions::OptionMap &Options) { } void RawStringLiteralCheck::registerMatchers(MatchFinder *Finder) { + // Raw string literals require C++11 or later. + if (!getLangOpts().CPlusPlus11) + return; + Finder->addMatcher( stringLiteral(unless(hasParent(predefinedExpr()))).bind("lit"), this); } void RawStringLiteralCheck::check(const MatchFinder::MatchResult &Result) { - // Raw string literals require C++11 or later. - if (!Result.Context->getLangOpts().CPlusPlus11) - return; - const auto *Literal = Result.Nodes.getNodeAs<StringLiteral>("lit"); if (Literal->getLocStart().isMacroID()) return; @@ -129,7 +129,7 @@ void RawStringLiteralCheck::replaceWithRawStringLiteral( const MatchFinder::MatchResult &Result, const StringLiteral *Literal) { CharSourceRange CharRange = Lexer::makeFileCharRange( CharSourceRange::getTokenRange(Literal->getSourceRange()), - *Result.SourceManager, Result.Context->getLangOpts()); + *Result.SourceManager, getLangOpts()); diag(Literal->getLocStart(), "escaped string literal can be written as a raw string literal") << FixItHint::CreateReplacement( diff --git a/clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp b/clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp index d81f156f954..6701fa45ced 100644 --- a/clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp @@ -45,6 +45,9 @@ const char LambdaId[] = "lambda"; } // namespace void RedundantVoidArgCheck::registerMatchers(MatchFinder *Finder) { + if (!getLangOpts().CPlusPlus) + return; + Finder->addMatcher(functionDecl(parameterCountIs(0), unless(isImplicit()), unless(isExternC())) .bind(FunctionId), @@ -72,10 +75,6 @@ void RedundantVoidArgCheck::registerMatchers(MatchFinder *Finder) { } void RedundantVoidArgCheck::check(const MatchFinder::MatchResult &Result) { - if (!Result.Context->getLangOpts().CPlusPlus) { - return; - } - const BoundNodes &Nodes = Result.Nodes; if (const auto *Function = Nodes.getNodeAs<FunctionDecl>(FunctionId)) { processFunctionDecl(Result, Function); @@ -118,16 +117,15 @@ void RedundantVoidArgCheck::processFunctionDecl( void RedundantVoidArgCheck::removeVoidArgumentTokens( const ast_matchers::MatchFinder::MatchResult &Result, SourceRange Range, StringRef GrammarLocation) { - CharSourceRange CharRange = Lexer::makeFileCharRange( - CharSourceRange::getTokenRange(Range), *Result.SourceManager, - Result.Context->getLangOpts()); - - std::string DeclText = Lexer::getSourceText(CharRange, *Result.SourceManager, - Result.Context->getLangOpts()) - .str(); - Lexer PrototypeLexer(CharRange.getBegin(), Result.Context->getLangOpts(), - DeclText.data(), DeclText.data(), - DeclText.data() + DeclText.size()); + CharSourceRange CharRange = + Lexer::makeFileCharRange(CharSourceRange::getTokenRange(Range), + *Result.SourceManager, getLangOpts()); + + std::string DeclText = + Lexer::getSourceText(CharRange, *Result.SourceManager, getLangOpts()) + .str(); + Lexer PrototypeLexer(CharRange.getBegin(), getLangOpts(), DeclText.data(), + DeclText.data(), DeclText.data() + DeclText.size()); enum TokenState { NothingYet, SawLeftParen, diff --git a/clang-tools-extra/clang-tidy/modernize/ShrinkToFitCheck.cpp b/clang-tools-extra/clang-tidy/modernize/ShrinkToFitCheck.cpp index 7438332abff..ef9201828ef 100644 --- a/clang-tools-extra/clang-tidy/modernize/ShrinkToFitCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/ShrinkToFitCheck.cpp @@ -20,6 +20,9 @@ namespace tidy { namespace modernize { void ShrinkToFitCheck::registerMatchers(MatchFinder *Finder) { + if (!getLangOpts().CPlusPlus11) + return; + // Swap as a function need not to be considered, because rvalue can not // be bound to a non-const reference. const auto ShrinkableAsMember = @@ -51,17 +54,13 @@ void ShrinkToFitCheck::registerMatchers(MatchFinder *Finder) { } void ShrinkToFitCheck::check(const MatchFinder::MatchResult &Result) { - const LangOptions &Opts = Result.Context->getLangOpts(); - - if (!Opts.CPlusPlus11) - return; - const auto *MemberCall = Result.Nodes.getNodeAs<CXXMemberCallExpr>("CopyAndSwapTrick"); const auto *Container = Result.Nodes.getNodeAs<Expr>("ContainerToShrink"); FixItHint Hint; if (!MemberCall->getLocStart().isMacroID()) { + const LangOptions &Opts = getLangOpts(); std::string ReplacementText; if (const auto *UnaryOp = llvm::dyn_cast<UnaryOperator>(Container)) { ReplacementText = diff --git a/clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp index 81fa73f95c5..3b91c6efbb1 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp @@ -104,7 +104,7 @@ void UseOverrideCheck::check(const MatchFinder::MatchResult &Result) { CharSourceRange FileRange = Lexer::makeFileCharRange( CharSourceRange::getTokenRange(Method->getSourceRange()), Sources, - Result.Context->getLangOpts()); + getLangOpts()); if (!FileRange.isValid()) return; diff --git a/clang-tools-extra/clang-tidy/mpi/TypeMismatchCheck.cpp b/clang-tools-extra/clang-tidy/mpi/TypeMismatchCheck.cpp index 143cc55f720..efe4aee5e44 100644 --- a/clang-tools-extra/clang-tidy/mpi/TypeMismatchCheck.cpp +++ b/clang-tools-extra/clang-tidy/mpi/TypeMismatchCheck.cpp @@ -296,8 +296,7 @@ void TypeMismatchCheck::check(const MatchFinder::MatchResult &Result) { addPair(0, 2); } } - checkArguments(BufferTypes, BufferExprs, MPIDatatypes, - Result.Context->getLangOpts()); + checkArguments(BufferTypes, BufferExprs, MPIDatatypes, getLangOpts()); } void TypeMismatchCheck::checkArguments(ArrayRef<const Type *> BufferTypes, diff --git a/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp b/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp index 11a588310f8..24719a27730 100644 --- a/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp +++ b/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp @@ -100,7 +100,7 @@ void AvoidConstParamsInDecls::check(const MatchFinder::MatchResult &Result) { CharSourceRange FileRange = Lexer::makeFileCharRange( CharSourceRange::getTokenRange(getTypeRange(*Param)), - *Result.SourceManager, Result.Context->getLangOpts()); + *Result.SourceManager, getLangOpts()); if (!FileRange.isValid()) return; diff --git a/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp b/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp index 01a44589703..79e4061c8c3 100644 --- a/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp @@ -69,9 +69,9 @@ void ContainerSizeEmptyCheck::check(const MatchFinder::MatchResult &Result) { const auto *BinaryOp = Result.Nodes.getNodeAs<BinaryOperator>("SizeBinaryOp"); const auto *E = Result.Nodes.getNodeAs<Expr>("STLObject"); FixItHint Hint; - std::string ReplacementText = Lexer::getSourceText( - CharSourceRange::getTokenRange(E->getSourceRange()), - *Result.SourceManager, Result.Context->getLangOpts()); + std::string ReplacementText = + Lexer::getSourceText(CharSourceRange::getTokenRange(E->getSourceRange()), + *Result.SourceManager, getLangOpts()); if (E->getType()->isPointerType()) ReplacementText += "->empty()"; else diff --git a/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp b/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp index e57f736f0ea..402bf510d23 100644 --- a/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp @@ -75,7 +75,7 @@ void NamespaceCommentCheck::check(const MatchFinder::MatchResult &Result) { SourceLocation Loc = AfterRBrace; Token Tok; // Skip whitespace until we find the next token. - while (Lexer::getRawToken(Loc, Tok, Sources, Result.Context->getLangOpts()) || + while (Lexer::getRawToken(Loc, Tok, Sources, getLangOpts()) || Tok.is(tok::semi)) { Loc = Loc.getLocWithOffset(1); } diff --git a/clang-tools-extra/clang-tidy/readability/RedundantControlFlowCheck.cpp b/clang-tools-extra/clang-tidy/readability/RedundantControlFlowCheck.cpp index 22f1111025c..4f8f8d175c9 100644 --- a/clang-tools-extra/clang-tidy/readability/RedundantControlFlowCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/RedundantControlFlowCheck.cpp @@ -80,16 +80,14 @@ void RedundantControlFlowCheck::issueDiagnostic( SourceLocation Start; if (Previous != Block->body_rend()) Start = Lexer::findLocationAfterToken( - dyn_cast<Stmt>(*Previous)->getLocEnd(), tok::semi, SM, - Result.Context->getLangOpts(), + dyn_cast<Stmt>(*Previous)->getLocEnd(), tok::semi, SM, getLangOpts(), /*SkipTrailingWhitespaceAndNewLine=*/true); if (!Start.isValid()) Start = StmtRange.getBegin(); auto RemovedRange = CharSourceRange::getCharRange( - Start, - Lexer::findLocationAfterToken(StmtRange.getEnd(), tok::semi, SM, - Result.Context->getLangOpts(), - /*SkipTrailingWhitespaceAndNewLine=*/true)); + Start, Lexer::findLocationAfterToken( + StmtRange.getEnd(), tok::semi, SM, getLangOpts(), + /*SkipTrailingWhitespaceAndNewLine=*/true)); diag(StmtRange.getBegin(), Diag) << FixItHint::CreateRemoval(RemovedRange); } diff --git a/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp b/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp index f36ed8219f4..3d1c863843f 100644 --- a/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp @@ -119,7 +119,7 @@ void RedundantSmartptrGetCheck::check(const MatchFinder::MatchResult &Result) { StringRef SmartptrText = Lexer::getSourceText( CharSourceRange::getTokenRange(Smartptr->getSourceRange()), - *Result.SourceManager, Result.Context->getLangOpts()); + *Result.SourceManager, getLangOpts()); // Replace foo->get() with *foo, and foo.get() with foo. std::string Replacement = Twine(IsPtrToPtr ? "*" : "", SmartptrText).str(); diag(GetCall->getLocStart(), "redundant get() call on smart pointer") diff --git a/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp b/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp index 151a6adcdad..be64335af70 100644 --- a/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp @@ -559,9 +559,9 @@ void SimplifyBooleanExprCheck::issueDiag( const ast_matchers::MatchFinder::MatchResult &Result, SourceLocation Loc, StringRef Description, SourceRange ReplacementRange, StringRef Replacement) { - CharSourceRange CharRange = Lexer::makeFileCharRange( - CharSourceRange::getTokenRange(ReplacementRange), *Result.SourceManager, - Result.Context->getLangOpts()); + CharSourceRange CharRange = + Lexer::makeFileCharRange(CharSourceRange::getTokenRange(ReplacementRange), + *Result.SourceManager, getLangOpts()); DiagnosticBuilder Diag = diag(Loc, Description); if (!containsDiscardedTokens(Result, CharRange)) diff --git a/clang-tools-extra/clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.cpp b/clang-tools-extra/clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.cpp index 9de2d408c0c..fe07127a609 100644 --- a/clang-tools-extra/clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.cpp @@ -53,12 +53,12 @@ void StaticDefinitionInAnonymousNamespaceCheck::check( Token Tok; SourceLocation Loc = Def->getSourceRange().getBegin(); while (Loc < Def->getSourceRange().getEnd() && - !Lexer::getRawToken(Loc, Tok, *Result.SourceManager, - Result.Context->getLangOpts(), true)) { + !Lexer::getRawToken(Loc, Tok, *Result.SourceManager, getLangOpts(), + true)) { SourceRange TokenRange(Tok.getLocation(), Tok.getEndLoc()); - StringRef SourceText = Lexer::getSourceText( - CharSourceRange::getTokenRange(TokenRange), - *Result.SourceManager, Result.Context->getLangOpts()); + StringRef SourceText = + Lexer::getSourceText(CharSourceRange::getTokenRange(TokenRange), + *Result.SourceManager, getLangOpts()); if (SourceText == "static") { Diag << FixItHint::CreateRemoval(TokenRange); break; diff --git a/clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp b/clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp index 3a7e5dc5533..e159bc97d23 100644 --- a/clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp @@ -51,9 +51,8 @@ void UniqueptrDeleteReleaseCheck::check( if (PtrExpr->getType()->isDependentType()) return; - SourceLocation AfterPtr = - Lexer::getLocForEndOfToken(PtrExpr->getLocEnd(), 0, *Result.SourceManager, - Result.Context->getLangOpts()); + SourceLocation AfterPtr = Lexer::getLocForEndOfToken( + PtrExpr->getLocEnd(), 0, *Result.SourceManager, getLangOpts()); diag(DeleteExpr->getLocStart(), "prefer '= nullptr' to 'delete x.release()' to reset unique_ptr<> " |