Author: xazax Date: Fri Sep 23 21:13:45 2016 New Revision: 282319 URL: http://llvm.org/viewvc/llvm-project?rev=282319&view=rev Log: [clang-tidy] Cleaning up language options.
Differential Revision: https://reviews.llvm.org/D24881 Modified: clang-tools-extra/trunk/clang-tidy/cert/StrToNumCheck.cpp clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp clang-tools-extra/trunk/clang-tidy/misc/AssertSideEffectCheck.cpp clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.cpp clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp clang-tools-extra/trunk/clang-tidy/misc/StringIntegerAssignmentCheck.cpp clang-tools-extra/trunk/clang-tidy/misc/SuspiciousStringCompareCheck.cpp clang-tools-extra/trunk/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.cpp clang-tools-extra/trunk/clang-tidy/misc/UnusedRAIICheck.cpp clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp clang-tools-extra/trunk/clang-tidy/modernize/RawStringLiteralCheck.cpp clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp clang-tools-extra/trunk/clang-tidy/modernize/ShrinkToFitCheck.cpp clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp clang-tools-extra/trunk/clang-tidy/mpi/TypeMismatchCheck.cpp clang-tools-extra/trunk/clang-tidy/readability/AvoidConstParamsInDecls.cpp clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.cpp clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.cpp clang-tools-extra/trunk/clang-tidy/readability/RedundantControlFlowCheck.cpp clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp clang-tools-extra/trunk/clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.cpp clang-tools-extra/trunk/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp Modified: clang-tools-extra/trunk/clang-tidy/cert/StrToNumCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/StrToNumCheck.cpp?rev=282319&r1=282318&r2=282319&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/cert/StrToNumCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/cert/StrToNumCheck.cpp Fri Sep 23 21:13:45 2016 @@ -214,7 +214,7 @@ void StrToNumCheck::check(const MatchFin // 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; Modified: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp?rev=282319&r1=282318&r2=282319&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp Fri Sep 23 21:13:45 2016 @@ -68,7 +68,7 @@ void ProTypeCstyleCastCheck::check(const 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 CastText.push_back('('); diag_builder << FixItHint::CreateInsertion( Lexer::getLocForEndOfToken(SubExpr->getLocEnd(), 0, - *Result.SourceManager, - Result.Context->getLangOpts()), + *Result.SourceManager, getLangOpts()), ")"); } auto ParenRange = CharSourceRange::getTokenRange( Modified: clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp?rev=282319&r1=282318&r2=282319&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp Fri Sep 23 21:13:45 2016 @@ -85,9 +85,8 @@ void AvoidCStyleCastsCheck::check(const 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 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 CastText.push_back('('); diag_builder << FixItHint::CreateInsertion( Lexer::getLocForEndOfToken(SubExpr->getLocEnd(), 0, SM, - Result.Context->getLangOpts()), + getLangOpts()), ")"); } diag_builder << FixItHint::CreateReplacement(ParenRange, CastText); Modified: clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp?rev=282319&r1=282318&r2=282319&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp Fri Sep 23 21:13:45 2016 @@ -92,7 +92,7 @@ void ExplicitConstructorCheck::check(con 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()) Modified: clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp?rev=282319&r1=282318&r2=282319&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp Fri Sep 23 21:13:45 2016 @@ -45,8 +45,7 @@ void TwineLocalCheck::check(const MatchF 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()"); Modified: clang-tools-extra/trunk/clang-tidy/misc/AssertSideEffectCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/AssertSideEffectCheck.cpp?rev=282319&r1=282318&r2=282319&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/misc/AssertSideEffectCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/misc/AssertSideEffectCheck.cpp Fri Sep 23 21:13:45 2016 @@ -101,7 +101,7 @@ void AssertSideEffectCheck::registerMatc 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; Modified: clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.cpp?rev=282319&r1=282318&r2=282319&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.cpp Fri Sep 23 21:13:45 2016 @@ -57,10 +57,9 @@ void InaccurateEraseCheck::check(const M 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); } Modified: clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp?rev=282319&r1=282318&r2=282319&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp Fri Sep 23 21:13:45 2016 @@ -117,7 +117,7 @@ void InefficientAlgorithmCheck::check(co FixItHint Hint; SourceManager &SM = *Result.SourceManager; - LangOptions LangOpts = Result.Context->getLangOpts(); + LangOptions LangOpts = getLangOpts(); CharSourceRange CallRange = CharSourceRange::getTokenRange(AlgCall->getSourceRange()); Modified: clang-tools-extra/trunk/clang-tidy/misc/StringIntegerAssignmentCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/StringIntegerAssignmentCheck.cpp?rev=282319&r1=282318&r2=282319&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/misc/StringIntegerAssignmentCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/misc/StringIntegerAssignmentCheck.cpp Fri Sep 23 21:13:45 2016 @@ -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, "'"); Modified: clang-tools-extra/trunk/clang-tidy/misc/SuspiciousStringCompareCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/SuspiciousStringCompareCheck.cpp?rev=282319&r1=282318&r2=282319&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/misc/SuspiciousStringCompareCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/misc/SuspiciousStringCompareCheck.cpp Fri Sep 23 21:13:45 2016 @@ -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(), Modified: clang-tools-extra/trunk/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp?rev=282319&r1=282318&r2=282319&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp Fri Sep 23 21:13:45 2016 @@ -107,10 +107,10 @@ void UniqueptrResetReleaseCheck::check(c 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; Modified: clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.cpp?rev=282319&r1=282318&r2=282319&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.cpp Fri Sep 23 21:13:45 2016 @@ -37,7 +37,7 @@ void UnusedAliasDeclsCheck::check(const AliasDecl->getLocStart(), Lexer::findLocationAfterToken( AliasDecl->getLocEnd(), tok::semi, *Result.SourceManager, - Result.Context->getLangOpts(), + getLangOpts(), /*SkipTrailingWhitespaceAndNewLine=*/true)); return; } Modified: clang-tools-extra/trunk/clang-tidy/misc/UnusedRAIICheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnusedRAIICheck.cpp?rev=282319&r1=282318&r2=282319&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/misc/UnusedRAIICheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/misc/UnusedRAIICheck.cpp Fri Sep 23 21:13:45 2016 @@ -85,7 +85,7 @@ void UnusedRAIICheck::check(const MatchF const auto *TL = selectFirst<TypeLoc>("t", Matches); D << FixItHint::CreateInsertion( Lexer::getLocForEndOfToken(TL->getLocEnd(), 0, *Result.SourceManager, - Result.Context->getLangOpts()), + getLangOpts()), Replacement); } Modified: clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp?rev=282319&r1=282318&r2=282319&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp Fri Sep 23 21:13:45 2016 @@ -64,8 +64,7 @@ void UnusedUsingDeclsCheck::check(const 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(); Modified: clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp?rev=282319&r1=282318&r2=282319&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp Fri Sep 23 21:13:45 2016 @@ -200,11 +200,10 @@ void PassByValueCheck::check(const Match 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); } Modified: clang-tools-extra/trunk/clang-tidy/modernize/RawStringLiteralCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/RawStringLiteralCheck.cpp?rev=282319&r1=282318&r2=282319&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/modernize/RawStringLiteralCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/modernize/RawStringLiteralCheck.cpp Fri Sep 23 21:13:45 2016 @@ -108,15 +108,15 @@ void RawStringLiteralCheck::storeOptions } 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::replaceWithR 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( Modified: clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp?rev=282319&r1=282318&r2=282319&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp Fri Sep 23 21:13:45 2016 @@ -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::registerMatc } 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::processFunct 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, Modified: clang-tools-extra/trunk/clang-tidy/modernize/ShrinkToFitCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ShrinkToFitCheck.cpp?rev=282319&r1=282318&r2=282319&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/modernize/ShrinkToFitCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/modernize/ShrinkToFitCheck.cpp Fri Sep 23 21:13:45 2016 @@ -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( } 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 = Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp?rev=282319&r1=282318&r2=282319&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp Fri Sep 23 21:13:45 2016 @@ -104,7 +104,7 @@ void UseOverrideCheck::check(const Match CharSourceRange FileRange = Lexer::makeFileCharRange( CharSourceRange::getTokenRange(Method->getSourceRange()), Sources, - Result.Context->getLangOpts()); + getLangOpts()); if (!FileRange.isValid()) return; Modified: clang-tools-extra/trunk/clang-tidy/mpi/TypeMismatchCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/mpi/TypeMismatchCheck.cpp?rev=282319&r1=282318&r2=282319&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/mpi/TypeMismatchCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/mpi/TypeMismatchCheck.cpp Fri Sep 23 21:13:45 2016 @@ -296,8 +296,7 @@ void TypeMismatchCheck::check(const Matc addPair(0, 2); } } - checkArguments(BufferTypes, BufferExprs, MPIDatatypes, - Result.Context->getLangOpts()); + checkArguments(BufferTypes, BufferExprs, MPIDatatypes, getLangOpts()); } void TypeMismatchCheck::checkArguments(ArrayRef<const Type *> BufferTypes, Modified: clang-tools-extra/trunk/clang-tidy/readability/AvoidConstParamsInDecls.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/AvoidConstParamsInDecls.cpp?rev=282319&r1=282318&r2=282319&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/readability/AvoidConstParamsInDecls.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/readability/AvoidConstParamsInDecls.cpp Fri Sep 23 21:13:45 2016 @@ -100,7 +100,7 @@ void AvoidConstParamsInDecls::check(cons CharSourceRange FileRange = Lexer::makeFileCharRange( CharSourceRange::getTokenRange(getTypeRange(*Param)), - *Result.SourceManager, Result.Context->getLangOpts()); + *Result.SourceManager, getLangOpts()); if (!FileRange.isValid()) return; Modified: clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.cpp?rev=282319&r1=282318&r2=282319&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.cpp Fri Sep 23 21:13:45 2016 @@ -69,9 +69,9 @@ void ContainerSizeEmptyCheck::check(cons 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 Modified: clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.cpp?rev=282319&r1=282318&r2=282319&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.cpp Fri Sep 23 21:13:45 2016 @@ -75,7 +75,7 @@ void NamespaceCommentCheck::check(const 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); } Modified: clang-tools-extra/trunk/clang-tidy/readability/RedundantControlFlowCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/RedundantControlFlowCheck.cpp?rev=282319&r1=282318&r2=282319&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/readability/RedundantControlFlowCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/readability/RedundantControlFlowCheck.cpp Fri Sep 23 21:13:45 2016 @@ -80,16 +80,14 @@ void RedundantControlFlowCheck::issueDia 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); } Modified: clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp?rev=282319&r1=282318&r2=282319&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp Fri Sep 23 21:13:45 2016 @@ -119,7 +119,7 @@ void RedundantSmartptrGetCheck::check(co 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") Modified: clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp?rev=282319&r1=282318&r2=282319&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp Fri Sep 23 21:13:45 2016 @@ -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)) Modified: clang-tools-extra/trunk/clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.cpp?rev=282319&r1=282318&r2=282319&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.cpp Fri Sep 23 21:13:45 2016 @@ -53,12 +53,12 @@ void StaticDefinitionInAnonymousNamespac 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; Modified: clang-tools-extra/trunk/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp?rev=282319&r1=282318&r2=282319&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp Fri Sep 23 21:13:45 2016 @@ -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<> " _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits