Author: Piotr Zegar Date: 2023-08-27T11:59:02Z New Revision: fc2a9ad10e21bda3dafbb85d8317ef5e3e5f99a1
URL: https://github.com/llvm/llvm-project/commit/fc2a9ad10e21bda3dafbb85d8317ef5e3e5f99a1 DIFF: https://github.com/llvm/llvm-project/commit/fc2a9ad10e21bda3dafbb85d8317ef5e3e5f99a1.diff LOG: [clang-tidy][NFC] Fix modernize-use-auto findings Fix issues found by clang-tidy in clang-tidy source directory. Added: Modified: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp clang-tools-extra/clang-tidy/abseil/DurationAdditionCheck.cpp clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp clang-tools-extra/clang-tidy/bugprone/StandaloneEmptyCheck.cpp clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp clang-tools-extra/clang-tidy/linuxkernel/MustCheckErrsCheck.cpp clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp clang-tools-extra/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp index f532d3ea7a941c..cbf21a0e2ae344 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp @@ -107,7 +107,7 @@ void yamlize(IO &IO, ClangTidyOptions::OptionMap &Val, bool, } else { // We need custom logic here to support the old method of specifying check // options using a list of maps containing key and value keys. - Input &I = reinterpret_cast<Input &>(IO); + auto &I = reinterpret_cast<Input &>(IO); if (isa<SequenceNode>(I.getCurrentNode())) { MappingNormalization<NOptionMap, ClangTidyOptions::OptionMap> NOpts(IO, Val); @@ -134,7 +134,7 @@ template <> void yamlize(IO &IO, ChecksVariant &Val, bool, EmptyContext &Ctx) { if (!IO.outputting()) { // Special case for reading from YAML // Must support reading from both a string or a list - Input &I = reinterpret_cast<Input &>(IO); + auto &I = reinterpret_cast<Input &>(IO); if (isa<ScalarNode, BlockScalarNode>(I.getCurrentNode())) { Val.AsString = std::string(); yamlize(IO, *Val.AsString, true, Ctx); diff --git a/clang-tools-extra/clang-tidy/abseil/DurationAdditionCheck.cpp b/clang-tools-extra/clang-tidy/abseil/DurationAdditionCheck.cpp index 2a31d60961703f..d4b8c9e6d89422 100644 --- a/clang-tools-extra/clang-tidy/abseil/DurationAdditionCheck.cpp +++ b/clang-tools-extra/clang-tidy/abseil/DurationAdditionCheck.cpp @@ -29,9 +29,8 @@ void DurationAdditionCheck::registerMatchers(MatchFinder *Finder) { } void DurationAdditionCheck::check(const MatchFinder::MatchResult &Result) { - const BinaryOperator *Binop = - Result.Nodes.getNodeAs<clang::BinaryOperator>("binop"); - const CallExpr *Call = Result.Nodes.getNodeAs<clang::CallExpr>("call"); + const auto *Binop = Result.Nodes.getNodeAs<clang::BinaryOperator>("binop"); + const auto *Call = Result.Nodes.getNodeAs<clang::CallExpr>("call"); // Don't try to replace things inside of macro definitions. if (Binop->getExprLoc().isMacroID() || Binop->getExprLoc().isInvalid()) diff --git a/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp b/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp index 7effb8250ae76b..b36144d1912fce 100644 --- a/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp +++ b/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp @@ -86,8 +86,7 @@ void StringFindStartswithCheck::check(const MatchFinder::MatchResult &Result) { const Expr *Haystack = Result.Nodes.getNodeAs<CXXMemberCallExpr>("findexpr") ->getImplicitObjectArgument(); assert(Haystack != nullptr); - const CXXMethodDecl *FindFun = - Result.Nodes.getNodeAs<CXXMethodDecl>("findfun"); + const auto *FindFun = Result.Nodes.getNodeAs<CXXMethodDecl>("findfun"); assert(FindFun != nullptr); bool Rev = FindFun->getName().contains("rfind"); diff --git a/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp b/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp index c3b47d41c46d64..cdaedd440959cc 100644 --- a/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp +++ b/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp @@ -110,7 +110,7 @@ void StructPackAlignCheck::check(const MatchFinder::MatchResult &Result) { } FixItHint FixIt; - AlignedAttr *Attribute = Struct->getAttr<AlignedAttr>(); + auto *Attribute = Struct->getAttr<AlignedAttr>(); std::string NewAlignQuantity = std::to_string((int)NewAlign.getQuantity()); if (Attribute) { FixIt = FixItHint::CreateReplacement( diff --git a/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp index d27fe0c08d72bb..356acf968db921 100644 --- a/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp @@ -196,7 +196,7 @@ void BranchCloneCheck::check(const MatchFinder::MatchResult &Result) { } if (const auto *SS = Result.Nodes.getNodeAs<SwitchStmt>("switch")) { - const CompoundStmt *Body = dyn_cast_or_null<CompoundStmt>(SS->getBody()); + const auto *Body = dyn_cast_or_null<CompoundStmt>(SS->getBody()); // Code like // switch (x) case 0: case 1: foobar(); diff --git a/clang-tools-extra/clang-tidy/bugprone/StandaloneEmptyCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/StandaloneEmptyCheck.cpp index a66f838f1c8fa3..2bce72cca98c6e 100644 --- a/clang-tools-extra/clang-tidy/bugprone/StandaloneEmptyCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/StandaloneEmptyCheck.cpp @@ -135,7 +135,7 @@ void StandaloneEmptyCheck::check(const MatchFinder::MatchResult &Result) { bool HasClear = !Candidates.empty(); if (HasClear) { - const CXXMethodDecl *Clear = llvm::cast<CXXMethodDecl>(Candidates.at(0)); + const auto *Clear = llvm::cast<CXXMethodDecl>(Candidates.at(0)); QualType RangeType = MemberCall->getImplicitObjectArgument()->getType(); bool QualifierIncompatible = (!Clear->isVolatile() && RangeType.isVolatileQualified()) || @@ -185,7 +185,7 @@ void StandaloneEmptyCheck::check(const MatchFinder::MatchResult &Result) { bool HasClear = !Candidates.empty(); if (HasClear) { - const CXXMethodDecl *Clear = llvm::cast<CXXMethodDecl>(Candidates.at(0)); + const auto *Clear = llvm::cast<CXXMethodDecl>(Candidates.at(0)); bool QualifierIncompatible = (!Clear->isVolatile() && Arg->getType().isVolatileQualified()) || Arg->getType().isConstQualified(); diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp index ff5a750a8dac45..7af096053e9e27 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp @@ -381,8 +381,7 @@ static const char *getInitializer(QualType QT, bool UseAssignment) { if (QT->isPointerType()) return " = nullptr"; - const BuiltinType *BT = - dyn_cast<BuiltinType>(QT.getCanonicalType().getTypePtr()); + const auto *BT = dyn_cast<BuiltinType>(QT.getCanonicalType().getTypePtr()); if (!BT) return DefaultInitializer; diff --git a/clang-tools-extra/clang-tidy/linuxkernel/MustCheckErrsCheck.cpp b/clang-tools-extra/clang-tidy/linuxkernel/MustCheckErrsCheck.cpp index 400ec0d4fabed6..3889fd536f2dcc 100644 --- a/clang-tools-extra/clang-tidy/linuxkernel/MustCheckErrsCheck.cpp +++ b/clang-tools-extra/clang-tidy/linuxkernel/MustCheckErrsCheck.cpp @@ -31,13 +31,13 @@ void MustCheckErrsCheck::registerMatchers(MatchFinder *Finder) { } void MustCheckErrsCheck::check(const MatchFinder::MatchResult &Result) { - const CallExpr *MatchedCallExpr = Result.Nodes.getNodeAs<CallExpr>("call"); + const auto *MatchedCallExpr = Result.Nodes.getNodeAs<CallExpr>("call"); if (MatchedCallExpr) { diag(MatchedCallExpr->getExprLoc(), "result from function %0 is unused") << MatchedCallExpr->getDirectCallee(); } - const CallExpr *MatchedTransitiveCallExpr = + const auto *MatchedTransitiveCallExpr = Result.Nodes.getNodeAs<CallExpr>("transitive_call"); if (MatchedTransitiveCallExpr) { diag(MatchedTransitiveCallExpr->getExprLoc(), diff --git a/clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp b/clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp index c2f72c8fc20a05..551f26ab9b9248 100644 --- a/clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp @@ -161,7 +161,7 @@ ConfusableIdentifierCheck::getContextInfo(const DeclContext *DC) { DC = DC->getParent(); } - if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(PrimaryContext)) { + if (const auto *RD = dyn_cast<CXXRecordDecl>(PrimaryContext)) { RD = RD->getDefinition(); if (RD) { Info.Bases.push_back(RD); diff --git a/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp b/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp index ff3b3a7ce5c39e..815c02a15492d1 100644 --- a/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp @@ -269,7 +269,7 @@ void PassByValueCheck::check(const MatchFinder::MatchResult &Result) { // Check if we can succesfully rewrite all declarations of the constructor. for (const ParmVarDecl *ParmDecl : collectParamDecls(Ctor, ParamDecl)) { TypeLoc ParamTL = ParmDecl->getTypeSourceInfo()->getTypeLoc(); - ReferenceTypeLoc RefTL = ParamTL.getAs<ReferenceTypeLoc>(); + auto RefTL = ParamTL.getAs<ReferenceTypeLoc>(); if (RefTL.isNull()) { // We cannot rewrite this instance. The type is probably hidden behind // some `typedef`. Do not offer a fix-it in this case. @@ -279,7 +279,7 @@ void PassByValueCheck::check(const MatchFinder::MatchResult &Result) { // Rewrite all declarations. for (const ParmVarDecl *ParmDecl : collectParamDecls(Ctor, ParamDecl)) { TypeLoc ParamTL = ParmDecl->getTypeSourceInfo()->getTypeLoc(); - ReferenceTypeLoc RefTL = ParamTL.getAs<ReferenceTypeLoc>(); + auto RefTL = ParamTL.getAs<ReferenceTypeLoc>(); TypeLoc ValueTL = RefTL.getPointeeLoc(); CharSourceRange TypeRange = CharSourceRange::getTokenRange( diff --git a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp index 00c7d419037fed..b81cfbcbfd16cc 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp @@ -434,8 +434,7 @@ void UseTrailingReturnTypeCheck::check(const MatchFinder::MatchResult &Result) { if (!TSI) return; - FunctionTypeLoc FTL = - TSI->getTypeLoc().IgnoreParens().getAs<FunctionTypeLoc>(); + auto FTL = TSI->getTypeLoc().IgnoreParens().getAs<FunctionTypeLoc>(); if (!FTL) { // FIXME: This may happen if we have __attribute__((...)) on the function. // We abort for now. Remove this when the function type location gets diff --git a/clang-tools-extra/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp index 06a2778b46dd7f..cffb931afa2d8b 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp @@ -49,7 +49,7 @@ void UseUncaughtExceptionsCheck::registerMatchers(MatchFinder *Finder) { void UseUncaughtExceptionsCheck::check(const MatchFinder::MatchResult &Result) { SourceLocation BeginLoc; SourceLocation EndLoc; - const CallExpr *C = Result.Nodes.getNodeAs<CallExpr>("init_call_expr"); + const auto *C = Result.Nodes.getNodeAs<CallExpr>("init_call_expr"); bool WarnOnly = false; if (C) { diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp index 102980d8dd10bf..e875717da247e3 100644 --- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp @@ -649,7 +649,7 @@ std::string IdentifierNamingCheck::HungarianNotation::getClassPrefix( std::string IdentifierNamingCheck::HungarianNotation::getEnumPrefix( const EnumConstantDecl *ECD) const { - const EnumDecl *ED = cast<EnumDecl>(ECD->getDeclContext()); + const auto *ED = cast<EnumDecl>(ECD->getDeclContext()); std::string Name = ED->getName().str(); if (std::string::npos != Name.find("enum")) { diff --git a/clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp b/clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp index 2d6a469252425d..d42fcba70e81b4 100644 --- a/clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp @@ -241,8 +241,7 @@ static SourceLocation getConstInsertionPoint(const CXXMethodDecl *M) { if (!TSI) return {}; - FunctionTypeLoc FTL = - TSI->getTypeLoc().IgnoreParens().getAs<FunctionTypeLoc>(); + auto FTL = TSI->getTypeLoc().IgnoreParens().getAs<FunctionTypeLoc>(); if (!FTL) return {}; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits