Re: [PATCH] D24881: [clang-tidy] Cleaning up language options.
This revision was automatically updated to reflect the committed changes. Closed by commit rL282319: [clang-tidy] Cleaning up language options. (authored by xazax). Changed prior to commit: https://reviews.llvm.org/D24881?vs=72341&id=72387#toc Repository: rL LLVM https://reviews.llvm.org/D24881 Files: 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 Index: clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp === --- clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp @@ -45,8 +45,7 @@ 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()"); Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp === --- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp @@ -68,7 +68,7 @@ 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 @@ CastText.push_back('('); diag_builder << FixItHint::CreateInsertion( Lexer::getLocForEndOfToken(SubExpr->getLocEnd(), 0, - *Result.SourceManager, - Result.Context->getLangOpts()), + *Result.SourceManager, getLangOpts()), ")"); } auto ParenRange = CharSourceRange::getTokenRange( Index: clang-tools-extra/trunk/clang-tidy/cert/StrToNumCheck.cpp === --- clang-tools-extra/trunk/clang-tidy/cert/StrToNumCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/cert/StrToNumCheck.cpp @@ -214,7 +214,7 @@ // 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->getTarge
Re: [PATCH] D24881: [clang-tidy] Cleaning up language options.
alexfh accepted this revision. alexfh added a comment. This revision is now accepted and ready to land. Thank you for the cleanup! Please clang-format-diff the files before submitting. Otherwise looks good. Repository: rL LLVM https://reviews.llvm.org/D24881 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24881: [clang-tidy] Cleaning up language options.
Eugene.Zelenko added a comment. I think it's reasonable to compile code in C++11 with minimal changes (only modernize-replace-auto-ptr is really needed) and test it before further modernization. Repository: rL LLVM https://reviews.llvm.org/D24881 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24881: [clang-tidy] Cleaning up language options.
xazax.hun added a comment. In https://reviews.llvm.org/D24881#551487, @Eugene.Zelenko wrote: > I think will be good idea to enable modernize-loop-convert, > modernize-use-auto, modernize-use-default, modernize-use-nullptr only in > C++11 mode. > > Probably modernize-avoid-bind code code be simplified too. As far as I can see there is a discrepancy between these modernization checks. Loop convert, use auto, use default, use nullptr is registered for older standards deliberately. See the following comment: // Only register the matchers for C++. Because this checker is used for // modernization, it is reasonable to run it on any C++ standard with the // assumption the user is trying to modernize their codebase. So basically the question is: should we require the users to run the clang tidy in C++11 mode (hence change their build settings) to get these modernization checks? I am okay with either of the answers but I wonder what do you think. Repository: rL LLVM https://reviews.llvm.org/D24881 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24881: [clang-tidy] Cleaning up language options.
Eugene.Zelenko added a subscriber: Eugene.Zelenko. Eugene.Zelenko added a comment. I think will be good idea to enable modernize-loop-convert, modernize-use-auto, modernize-use-default, modernize-use-nullptr only in C++11 mode. Probably modernize-avoid-bind code code be simplified too. Repository: rL LLVM https://reviews.llvm.org/D24881 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24881: [clang-tidy] Cleaning up language options.
xazax.hun created this revision. xazax.hun added reviewers: hokein, alexfh. xazax.hun added a subscriber: cfe-commits. xazax.hun set the repository for this revision to rL LLVM. xazax.hun added a project: clang-tools-extra. Herald added a subscriber: nemanjai. In some cases do not register the matcher when the check method of a checker should not run anyways. Refactor some checks to use a shorter way to get language options. Repository: rL LLVM https://reviews.llvm.org/D24881 Files: clang-tidy/cert/StrToNumCheck.cpp clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp clang-tidy/google/AvoidCStyleCastsCheck.cpp clang-tidy/google/ExplicitConstructorCheck.cpp clang-tidy/llvm/TwineLocalCheck.cpp clang-tidy/misc/AssertSideEffectCheck.cpp clang-tidy/misc/InaccurateEraseCheck.cpp clang-tidy/misc/InefficientAlgorithmCheck.cpp clang-tidy/misc/StringIntegerAssignmentCheck.cpp clang-tidy/misc/SuspiciousStringCompareCheck.cpp clang-tidy/misc/UniqueptrResetReleaseCheck.cpp clang-tidy/misc/UnusedAliasDeclsCheck.cpp clang-tidy/misc/UnusedRAIICheck.cpp clang-tidy/misc/UnusedUsingDeclsCheck.cpp clang-tidy/modernize/PassByValueCheck.cpp clang-tidy/modernize/RawStringLiteralCheck.cpp clang-tidy/modernize/RedundantVoidArgCheck.cpp clang-tidy/modernize/ShrinkToFitCheck.cpp clang-tidy/modernize/UseOverrideCheck.cpp clang-tidy/mpi/TypeMismatchCheck.cpp clang-tidy/readability/AvoidConstParamsInDecls.cpp clang-tidy/readability/ContainerSizeEmptyCheck.cpp clang-tidy/readability/NamespaceCommentCheck.cpp clang-tidy/readability/RedundantControlFlowCheck.cpp clang-tidy/readability/RedundantSmartptrGetCheck.cpp clang-tidy/readability/SimplifyBooleanExprCheck.cpp clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.cpp clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp Index: clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp === --- clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp +++ clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp @@ -53,7 +53,7 @@ SourceLocation AfterPtr = Lexer::getLocForEndOfToken(PtrExpr->getLocEnd(), 0, *Result.SourceManager, - Result.Context->getLangOpts()); + getLangOpts()); diag(DeleteExpr->getLocStart(), "prefer '= nullptr' to 'delete x.release()' to reset unique_ptr<> " Index: clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.cpp === --- clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.cpp +++ clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.cpp @@ -54,11 +54,11 @@ SourceLocation Loc = Def->getSourceRange().getBegin(); while (Loc < Def->getSourceRange().getEnd() && !Lexer::getRawToken(Loc, Tok, *Result.SourceManager, - Result.Context->getLangOpts(), true)) { + getLangOpts(), true)) { SourceRange TokenRange(Tok.getLocation(), Tok.getEndLoc()); StringRef SourceText = Lexer::getSourceText( CharSourceRange::getTokenRange(TokenRange), -*Result.SourceManager, Result.Context->getLangOpts()); +*Result.SourceManager, getLangOpts()); if (SourceText == "static") { Diag << FixItHint::CreateRemoval(TokenRange); break; Index: clang-tidy/readability/SimplifyBooleanExprCheck.cpp === --- clang-tidy/readability/SimplifyBooleanExprCheck.cpp +++ clang-tidy/readability/SimplifyBooleanExprCheck.cpp @@ -561,7 +561,7 @@ StringRef Replacement) { CharSourceRange CharRange = Lexer::makeFileCharRange( CharSourceRange::getTokenRange(ReplacementRange), *Result.SourceManager, - Result.Context->getLangOpts()); + getLangOpts()); DiagnosticBuilder Diag = diag(Loc, Description); if (!containsDiscardedTokens(Result, CharRange)) Index: clang-tidy/readability/RedundantSmartptrGetCheck.cpp === --- clang-tidy/readability/RedundantSmartptrGetCheck.cpp +++ clang-tidy/readability/RedundantSmartptrGetCheck.cpp @@ -119,7 +119,7 @@ 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") Index: clang-tidy/readability/RedundantControlFlowCheck.cpp === --- clang-tidy/readability/RedundantControlFlowCheck.cpp +++ clang-tidy/readability/RedundantControlFlowCheck.cpp @@ -81,14 +81