Author: Salman Javed Date: 2021-11-02T20:14:25+13:00 New Revision: ade0662c51b571ea7e80fcb53516485086032d7f
URL: https://github.com/llvm/llvm-project/commit/ade0662c51b571ea7e80fcb53516485086032d7f DIFF: https://github.com/llvm/llvm-project/commit/ade0662c51b571ea7e80fcb53516485086032d7f.diff LOG: [clang-tidy] Fix lint warnings in clang-tidy source code (NFC) Run clang-tidy on all source files under `clang-tools-extra/clang-tidy` with `-header-filter=clang-tidy.*` and make suggested corrections. Differential Revision: https://reviews.llvm.org/D112864 Added: Modified: clang-tools-extra/clang-tidy/ClangTidy.cpp clang-tools-extra/clang-tidy/ClangTidy.h clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h clang-tools-extra/clang-tidy/ClangTidyOptions.h clang-tools-extra/clang-tidy/abseil/DurationDivisionCheck.h clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp clang-tools-extra/clang-tidy/abseil/DurationRewriter.h clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp clang-tools-extra/clang-tidy/bugprone/CopyConstructorInitCheck.h clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp clang-tools-extra/clang-tidy/bugprone/MultipleStatementMacroCheck.cpp clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.h clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.h clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.h clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.h clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.h clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.h clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.h clang-tools-extra/clang-tidy/performance/ImplicitConversionInLoopCheck.cpp clang-tools-extra/clang-tidy/performance/ImplicitConversionInLoopCheck.h clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.h clang-tools-extra/clang-tidy/plugin/ClangTidyPlugin.cpp clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.h clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.h clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp clang-tools-extra/clang-tidy/utils/ASTUtils.cpp clang-tools-extra/clang-tidy/utils/ASTUtils.h clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp clang-tools-extra/clang-tidy/utils/IncludeSorter.h clang-tools-extra/clang-tidy/utils/LexerUtils.cpp clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h clang-tools-extra/clang-tidy/utils/TypeTraits.h Removed: ################################################################################ diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp index 73d66b980a5e..7de313ad4da6 100644 --- a/clang-tools-extra/clang-tidy/ClangTidy.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp @@ -385,7 +385,7 @@ static CheckersList getAnalyzerCheckersAndPackages(ClangTidyContext &Context, #endif // CLANG_TIDY_ENABLE_STATIC_ANALYZER std::unique_ptr<clang::ASTConsumer> -ClangTidyASTConsumerFactory::CreateASTConsumer( +ClangTidyASTConsumerFactory::createASTConsumer( clang::CompilerInstance &Compiler, StringRef File) { // FIXME: Move this to a separate method, so that CreateASTConsumer doesn't // modify Compiler. @@ -573,7 +573,7 @@ runClangTidy(clang::tidy::ClangTidyContext &Context, Action(ClangTidyASTConsumerFactory *Factory) : Factory(Factory) {} std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &Compiler, StringRef File) override { - return Factory->CreateASTConsumer(Compiler, File); + return Factory->createASTConsumer(Compiler, File); } private: diff --git a/clang-tools-extra/clang-tidy/ClangTidy.h b/clang-tools-extra/clang-tidy/ClangTidy.h index bbe4fe69123f..507d1ce6e572 100644 --- a/clang-tools-extra/clang-tidy/ClangTidy.h +++ b/clang-tools-extra/clang-tidy/ClangTidy.h @@ -38,7 +38,7 @@ class ClangTidyASTConsumerFactory { /// Returns an ASTConsumer that runs the specified clang-tidy checks. std::unique_ptr<clang::ASTConsumer> - CreateASTConsumer(clang::CompilerInstance &Compiler, StringRef File); + createASTConsumer(clang::CompilerInstance &Compiler, StringRef File); /// Get the list of enabled checks. std::vector<std::string> getCheckNames(); diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp index 2d3eb371b695..456de0e979db 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp @@ -66,7 +66,7 @@ class ClangTidyDiagnosticRenderer : public DiagnosticRenderer { ? tooling::DiagnosticMessage(Message, Loc.getManager(), Loc) : tooling::DiagnosticMessage(Message); - // Make sure that if a TokenRange is receieved from the check it is unfurled + // Make sure that if a TokenRange is received from the check it is unfurled // into a real CharRange for the diagnostic printer later. // Whatever we store here gets decoupled from the current SourceManager, so // we **have to** know the exact position and length of the highlight. diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h index 84925e81dc08..f93deae64bb3 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h +++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h @@ -23,10 +23,10 @@ class CompilerInstance; class SourceManager; namespace ast_matchers { class MatchFinder; -} +} // namespace ast_matchers namespace tooling { class CompilationDatabase; -} +} // namespace tooling namespace tidy { diff --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.h b/clang-tools-extra/clang-tidy/ClangTidyOptions.h index d8a4a14f5b52..3f09d39df13d 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyOptions.h +++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.h @@ -108,7 +108,7 @@ struct ClangTidyOptions { std::string Value; /// Priority stores relative precedence of the value loaded from config - /// files to disambigute local vs global value from diff erent levels. + /// files to disambiguate local vs global value from diff erent levels. unsigned Priority; }; typedef std::pair<std::string, std::string> StringPair; @@ -129,8 +129,8 @@ struct ClangTidyOptions { /// and using a FileOptionsProvider, it will take a configuration file in the /// parent directory (if any exists) and apply this config file on top of the /// parent one. IF true and using a ConfigOptionsProvider, it will apply this - /// config on top of any configuation file it finds in the directory using the - /// same logic as FileOptionsProvider. If false or missing, only this + /// config on top of any configuration file it finds in the directory using + /// the same logic as FileOptionsProvider. If false or missing, only this /// configuration file will be used. llvm::Optional<bool> InheritParentConfig; diff --git a/clang-tools-extra/clang-tidy/abseil/DurationDivisionCheck.h b/clang-tools-extra/clang-tidy/abseil/DurationDivisionCheck.h index a4e4dd57a4d8..0bb603b6ba5d 100644 --- a/clang-tools-extra/clang-tidy/abseil/DurationDivisionCheck.h +++ b/clang-tools-extra/clang-tidy/abseil/DurationDivisionCheck.h @@ -26,8 +26,8 @@ class DurationDivisionCheck : public ClangTidyCheck { bool isLanguageVersionSupported(const LangOptions &LangOpts) const override { return LangOpts.CPlusPlus; } - void registerMatchers(ast_matchers::MatchFinder *finder) override; - void check(const ast_matchers::MatchFinder::MatchResult &result) override; + void registerMatchers(ast_matchers::MatchFinder *Finder) override; + void check(const ast_matchers::MatchFinder::MatchResult &Result) override; }; } // namespace abseil diff --git a/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp b/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp index 7da75fad589b..aa839beddac6 100644 --- a/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp +++ b/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp @@ -145,7 +145,7 @@ void DurationFactoryScaleCheck::check(const MatchFinder::MatchResult &Result) { return; // We first handle the cases of literal zero (both float and integer). - if (IsLiteralZero(Result, *Arg)) { + if (isLiteralZero(Result, *Arg)) { diag(Call->getBeginLoc(), "use ZeroDuration() for zero-length time intervals") << FixItHint::CreateReplacement(Call->getSourceRange(), diff --git a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp index 84c7a9fa9247..671ed65d3c57 100644 --- a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp +++ b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp @@ -157,7 +157,7 @@ llvm::StringRef getTimeInverseForScale(DurationScale Scale) { } /// Returns `true` if `Node` is a value which evaluates to a literal `0`. -bool IsLiteralZero(const MatchFinder::MatchResult &Result, const Expr &Node) { +bool isLiteralZero(const MatchFinder::MatchResult &Result, const Expr &Node) { auto ZeroMatcher = anyOf(integerLiteral(equals(0)), floatLiteral(equals(0.0))); @@ -276,7 +276,7 @@ std::string rewriteExprFromNumberToDuration( rewriteInverseDurationCall(Result, Scale, RootNode)) return *MaybeRewrite; - if (IsLiteralZero(Result, RootNode)) + if (isLiteralZero(Result, RootNode)) return std::string("absl::ZeroDuration()"); return (llvm::Twine(getDurationFactoryForScale(Scale)) + "(" + @@ -294,7 +294,7 @@ std::string rewriteExprFromNumberToTime( rewriteInverseTimeCall(Result, Scale, RootNode)) return *MaybeRewrite; - if (IsLiteralZero(Result, RootNode)) + if (isLiteralZero(Result, RootNode)) return std::string("absl::UnixEpoch()"); return (llvm::Twine(getTimeFactoryForScale(Scale)) + "(" + diff --git a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.h b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.h index 1ae312c63432..135d15b635cd 100644 --- a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.h +++ b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.h @@ -33,10 +33,10 @@ llvm::StringRef getDurationFactoryForScale(DurationScale Scale); /// Given a 'Scale', return the appropriate factory function call for /// constructing a `Time` for that scale. -llvm::StringRef getTimeFactoryForScale(DurationScale scale); +llvm::StringRef getTimeFactoryForScale(DurationScale Scale); // Determine if `Node` represents a literal floating point or integral zero. -bool IsLiteralZero(const ast_matchers::MatchFinder::MatchResult &Result, +bool isLiteralZero(const ast_matchers::MatchFinder::MatchResult &Result, const Expr &Node); /// Possibly strip a floating point cast expression. @@ -77,7 +77,7 @@ const std::pair<llvm::StringRef, llvm::StringRef> & getDurationInverseForScale(DurationScale Scale); /// Returns the Time inverse function name for a given `Scale`. -llvm::StringRef getTimeInverseForScale(DurationScale scale); +llvm::StringRef getTimeInverseForScale(DurationScale Scale); /// Assuming `Node` has type `double` or `int` representing a time interval of /// `Scale`, return the expression to make it a suitable `Duration`. diff --git a/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp b/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp index aa43e7dc3885..5741c0d505d5 100644 --- a/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp +++ b/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp @@ -97,7 +97,7 @@ void StringFindStartswithCheck::check(const MatchFinder::MatchResult &Result) { ", " + NeedleExprCode + ")") .str()); - // Create a preprocessor #include FixIt hint (CreateIncludeInsertion checks + // Create a preprocessor #include FixIt hint (createIncludeInsertion checks // whether this already exists). Diagnostic << IncludeInserter.createIncludeInsertion( Source.getFileID(ComparisonExpr->getBeginLoc()), diff --git a/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp b/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp index 0290789e76bf..75797c185dec 100644 --- a/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp +++ b/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp @@ -240,7 +240,7 @@ bool UnrollLoopsCheck::extractValue(int &Value, const BinaryOperator *Op, else if (RHS->isEvaluatable(*Context)) RHS->EvaluateAsRValue(Result, *Context); else - return false; // Cannot evalue either side. + return false; // Cannot evaluate either side. if (!Result.Val.isInt()) return false; // Cannot check number of iterations, return false to be // safe. diff --git a/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp index 86e3f3b7da6a..f5f418b13956 100644 --- a/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp @@ -43,7 +43,7 @@ static bool areSwitchBranchesIdentical(const SwitchBranch LHS, for (size_t I = 0, Size = LHS.size(); I < Size; I++) { // NOTE: We strip goto labels and annotations in addition to stripping // the `case X:` or `default:` labels, but it is very unlikely that this - // would casue false positives in real-world code. + // would cause false positives in real-world code. if (!areStatementsIdentical(LHS[I]->stripLabelLikeStatements(), RHS[I]->stripLabelLikeStatements(), Context)) { return false; @@ -187,10 +187,10 @@ void BranchCloneCheck::check(const MatchFinder::MatchResult &Result) { Branches.back().push_back(S); } - auto End = Branches.end(); - auto BeginCurrent = Branches.begin(); + auto *End = Branches.end(); + auto *BeginCurrent = Branches.begin(); while (BeginCurrent < End) { - auto EndCurrent = BeginCurrent + 1; + auto *EndCurrent = BeginCurrent + 1; while (EndCurrent < End && areSwitchBranchesIdentical(*BeginCurrent, *EndCurrent, Context)) { ++EndCurrent; diff --git a/clang-tools-extra/clang-tidy/bugprone/CopyConstructorInitCheck.h b/clang-tools-extra/clang-tidy/bugprone/CopyConstructorInitCheck.h index f5ee77c8c7ba..ade353aa4940 100644 --- a/clang-tools-extra/clang-tidy/bugprone/CopyConstructorInitCheck.h +++ b/clang-tools-extra/clang-tidy/bugprone/CopyConstructorInitCheck.h @@ -31,7 +31,7 @@ class CopyConstructorInitCheck : public ClangTidyCheck { void check(const ast_matchers::MatchFinder::MatchResult &Result) override; }; -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang diff --git a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp index d111016ca345..771a8780b070 100644 --- a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp @@ -1100,7 +1100,7 @@ class UserDefinedConversionSelector { /// an implicit conversion. void addConversion(const CXXMethodDecl *ConvFun, QualType FromType, QualType ToType) { - // Try to go from the FromType to the ToType wiht only a single implicit + // Try to go from the FromType to the ToType with only a single implicit // conversion, to see if the conversion function is applicable. MixData Mix = calculateMixability( Check, FromType, ToType, ConvFun->getASTContext(), @@ -1553,7 +1553,7 @@ static bool isIgnoredParameter(const TheCheck &Check, const ParmVarDecl *Node) { } /// This namespace contains the implementations for the suppression of -/// diagnostics from similaly used ("related") parameters. +/// diagnostics from similarly-used ("related") parameters. namespace relatedness_heuristic { static constexpr std::size_t SmallDataStructureSize = 4; diff --git a/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp index 857ef15f9d0c..568f139bdb85 100644 --- a/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp @@ -112,7 +112,8 @@ void ForwardingReferenceOverloadCheck::check( // Every parameter after the first must have a default value. const auto *Ctor = Result.Nodes.getNodeAs<CXXConstructorDecl>("ctor"); - for (auto Iter = Ctor->param_begin() + 1; Iter != Ctor->param_end(); ++Iter) { + for (auto *Iter = Ctor->param_begin() + 1; Iter != Ctor->param_end(); + ++Iter) { if (!(*Iter)->hasDefaultArg()) return; } diff --git a/clang-tools-extra/clang-tidy/bugprone/MultipleStatementMacroCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/MultipleStatementMacroCheck.cpp index 4a8388c61ee0..e57feaf029a8 100644 --- a/clang-tools-extra/clang-tidy/bugprone/MultipleStatementMacroCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/MultipleStatementMacroCheck.cpp @@ -39,7 +39,7 @@ const Stmt *nextStmt(const MatchFinder::MatchResult &Result, const Stmt *S) { using ExpansionRanges = std::vector<SourceRange>; -/// \bried Get all the macro expansion ranges related to `Loc`. +/// \brief Get all the macro expansion ranges related to `Loc`. /// /// The result is ordered from most inner to most outer. ExpansionRanges getExpansionRanges(SourceLocation Loc, diff --git a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp index df2968e2e37c..8da046955425 100644 --- a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp @@ -152,7 +152,7 @@ getFailureInfoImpl(StringRef Name, bool IsInGlobalNamespace, } Optional<RenamerClangTidyCheck::FailureInfo> -ReservedIdentifierCheck::GetDeclFailureInfo(const NamedDecl *Decl, +ReservedIdentifierCheck::getDeclFailureInfo(const NamedDecl *Decl, const SourceManager &) const { assert(Decl && Decl->getIdentifier() && !Decl->getName().empty() && !Decl->isImplicit() && @@ -163,14 +163,14 @@ ReservedIdentifierCheck::GetDeclFailureInfo(const NamedDecl *Decl, } Optional<RenamerClangTidyCheck::FailureInfo> -ReservedIdentifierCheck::GetMacroFailureInfo(const Token &MacroNameTok, +ReservedIdentifierCheck::getMacroFailureInfo(const Token &MacroNameTok, const SourceManager &) const { return getFailureInfoImpl(MacroNameTok.getIdentifierInfo()->getName(), true, getLangOpts(), Invert, AllowedIdentifiers); } RenamerClangTidyCheck::DiagInfo -ReservedIdentifierCheck::GetDiagInfo(const NamingCheckId &ID, +ReservedIdentifierCheck::getDiagInfo(const NamingCheckId &ID, const NamingCheckFailure &Failure) const { return DiagInfo{Message, [&](DiagnosticBuilder &Diag) { Diag << ID.second diff --git a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.h b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.h index fa570902f778..dc1206b5901b 100644 --- a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.h +++ b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.h @@ -41,12 +41,12 @@ class ReservedIdentifierCheck final : public RenamerClangTidyCheck { private: llvm::Optional<FailureInfo> - GetDeclFailureInfo(const NamedDecl *Decl, + getDeclFailureInfo(const NamedDecl *Decl, const SourceManager &SM) const override; llvm::Optional<FailureInfo> - GetMacroFailureInfo(const Token &MacroNameTok, + getMacroFailureInfo(const Token &MacroNameTok, const SourceManager &SM) const override; - DiagInfo GetDiagInfo(const NamingCheckId &ID, + DiagInfo getDiagInfo(const NamingCheckId &ID, const NamingCheckFailure &Failure) const override; }; diff --git a/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp index 44a19b1f824a..5bdf01c098dc 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp @@ -176,7 +176,7 @@ void SizeofExpressionCheck::registerMatchers(MatchFinder *Finder) { .bind("sizeof-pointer-to-aggregate"), this); - // Detect expression like: sizeof(epxr) <= k for a suspicious constant 'k'. + // Detect expression like: sizeof(expr) <= k for a suspicious constant 'k'. if (WarnOnSizeOfCompareToConstant) { Finder->addMatcher( binaryOperator(matchers::isRelationalOperator(), diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp index a99492d29d5f..8542f631a2e4 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp @@ -131,7 +131,7 @@ void SuspiciousStringCompareCheck::registerMatchers(MatchFinder *Finder) { this); } - // Detect suspicious cast to an inconsistant type (i.e. not integer type). + // Detect suspicious cast to an inconsistent type (i.e. not integer type). Finder->addMatcher( traverse(TK_AsIs, implicitCastExpr(unless(hasType(isInteger())), diff --git a/clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp index b87bb9e8ca95..9b8d8d7bf5f4 100644 --- a/clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp @@ -84,9 +84,9 @@ void UnusedRaiiCheck::check(const MatchFinder::MatchResult &Result) { auto SR = SourceRange(Node->getLParenLoc(), Node->getRParenLoc()); auto DefaultConstruction = Node->getNumArgs() == 0; if (!DefaultConstruction) { - auto FirstArg = Node->getArg(0); + auto *FirstArg = Node->getArg(0); DefaultConstruction = isa<CXXDefaultArgExpr>(FirstArg); - if (auto ILE = dyn_cast<InitListExpr>(FirstArg)) { + if (auto *ILE = dyn_cast<InitListExpr>(FirstArg)) { DefaultConstruction = ILE->getNumInits() == 0; SR = SourceRange(ILE->getLBraceLoc(), ILE->getRBraceLoc()); } diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp index f58cc06987fe..13bb7246fd43 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp @@ -52,7 +52,7 @@ void OwningMemoryCheck::registerMatchers(MatchFinder *Finder) { callExpr(callee(functionDecl(LegacyCreatorFunctions))); // C-style functions like `::malloc()` sometimes create owners as void* // which is expected to be cast to the correct type in C++. This case - // must be catched explicitly. + // must be caught explicitly. const auto LegacyOwnerCast = castExpr(hasSourceExpression(CreatesLegacyOwner)); // Functions that do manual resource management but cannot be updated to use diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp index aa9a0ca80458..1540a451b46d 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp @@ -122,9 +122,9 @@ enum class InitializerPlacement { // insert into the initializer list of a constructor. We use this to ensure // proper absolute ordering according to the class declaration relative to the // (perhaps improper) ordering in the existing initializer list, if any. -struct IntializerInsertion { - IntializerInsertion(InitializerPlacement Placement, - const CXXCtorInitializer *Where) +struct InitializerInsertion { + InitializerInsertion(InitializerPlacement Placement, + const CXXCtorInitializer *Where) : Placement(Placement), Where(Where) {} SourceLocation getLocation(const ASTContext &Context, @@ -186,11 +186,11 @@ const RecordDecl *getCanonicalRecordDecl(const QualType &Type) { } template <typename R, typename T> -SmallVector<IntializerInsertion, 16> +SmallVector<InitializerInsertion, 16> computeInsertions(const CXXConstructorDecl::init_const_range &Inits, const R &OrderedDecls, const SmallPtrSetImpl<const T *> &DeclsToInit) { - SmallVector<IntializerInsertion, 16> Insertions; + SmallVector<InitializerInsertion, 16> Insertions; Insertions.emplace_back(InitializerPlacement::New, nullptr); typename R::const_iterator Decl = std::begin(OrderedDecls); diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp index 93081133190f..7cc3d749120c 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp @@ -71,7 +71,7 @@ void SlicingCheck::registerMatchers(MatchFinder *Finder) { /// Warns on methods overridden in DerivedDecl with respect to BaseDecl. /// FIXME: this warns on all overrides outside of the sliced path in case of /// multiple inheritance. -void SlicingCheck::DiagnoseSlicedOverriddenMethods( +void SlicingCheck::diagnoseSlicedOverriddenMethods( const Expr &Call, const CXXRecordDecl &DerivedDecl, const CXXRecordDecl &BaseDecl) { if (DerivedDecl.getCanonicalDecl() == BaseDecl.getCanonicalDecl()) @@ -92,7 +92,7 @@ void SlicingCheck::DiagnoseSlicedOverriddenMethods( if (const auto *BaseRecordType = Base.getType()->getAs<RecordType>()) { if (const auto *BaseRecord = cast_or_null<CXXRecordDecl>( BaseRecordType->getDecl()->getDefinition())) - DiagnoseSlicedOverriddenMethods(Call, *BaseRecord, BaseDecl); + diagnoseSlicedOverriddenMethods(Call, *BaseRecord, BaseDecl); } } } @@ -115,7 +115,7 @@ void SlicingCheck::check(const MatchFinder::MatchResult &Result) { // class A { virtual void f(); }; // class B : public A {}; // because in that case calling A::f is the same as calling B::f. - DiagnoseSlicedOverriddenMethods(*Call, *DerivedDecl, *BaseDecl); + diagnoseSlicedOverriddenMethods(*Call, *DerivedDecl, *BaseDecl); // Warn when slicing member variables. const auto &BaseLayout = diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.h b/clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.h index 002c724f86b8..5cf0099676d6 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.h +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.h @@ -32,7 +32,7 @@ class SlicingCheck : public ClangTidyCheck { void check(const ast_matchers::MatchFinder::MatchResult &Result) override; private: - void DiagnoseSlicedOverriddenMethods(const Expr &call, + void diagnoseSlicedOverriddenMethods(const Expr &Call, const CXXRecordDecl &DerivedDecl, const CXXRecordDecl &BaseDecl); }; diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h b/clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h index ada765df3c4c..5409eb17525b 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h @@ -77,7 +77,7 @@ class SpecialMemberFunctionsCheck : public ClangTidyCheck { } // namespace clang namespace llvm { -/// Specialisation of DenseMapInfo to allow ClassDefId objects in DenseMaps +/// Specialization of DenseMapInfo to allow ClassDefId objects in DenseMaps /// FIXME: Move this to the corresponding cpp file as is done for /// clang-tidy/readability/IdentifierNamingCheck.cpp. template <> diff --git a/clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.h b/clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.h index 801124cd5f67..dc5dd8b87521 100644 --- a/clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.h +++ b/clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.h @@ -32,8 +32,8 @@ class MultipleInheritanceCheck : public ClangTidyCheck { void onEndOfTranslationUnit() override { InterfaceMap.clear(); } private: - void addNodeToInterfaceMap(const CXXRecordDecl *Node, bool isInterface); - bool getInterfaceStatus(const CXXRecordDecl *Node, bool &isInterface) const; + void addNodeToInterfaceMap(const CXXRecordDecl *Node, bool IsInterface); + bool getInterfaceStatus(const CXXRecordDecl *Node, bool &IsInterface) const; bool isCurrentClassInterface(const CXXRecordDecl *Node) const; bool isInterface(const CXXRecordDecl *Node); diff --git a/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp b/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp index 3e4c39d94193..8f8bd7a77ceb 100644 --- a/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp +++ b/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp @@ -35,7 +35,7 @@ std::string LLVMHeaderGuardCheck::getHeaderGuard(StringRef Filename, Guard = Guard.substr(PosToolsClang + std::strlen("tools/")); // Unlike LLVM svn, LLVM git monorepo is named llvm-project, so we replace - // "/llvm-project/" with the cannonical "/llvm/". + // "/llvm-project/" with the canonical "/llvm/". const static StringRef LLVMProject = "/llvm-project/"; size_t PosLLVMProject = Guard.rfind(std::string(LLVMProject)); if (PosLLVMProject != StringRef::npos) diff --git a/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp b/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp index 1200230c53ed..e81823795489 100644 --- a/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp @@ -171,7 +171,7 @@ CallStackTy pathfindSomeCycle(ArrayRef<CallGraphNode *> SCC) { SmartSmallSetVector<CallGraphNode::CallRecord, SmallCallStackSize> CallStackSet; - // Arbitrairly take the first element of SCC as entry point. + // Arbitrarily take the first element of SCC as entry point. CallGraphNode::CallRecord EntryNode(SCC.front(), /*CallExpr=*/nullptr); // Continue recursing into subsequent callees that are part of this SCC, // and are thus known to be part of the call graph loop, until loop forms. diff --git a/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp b/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp index 6a8436054b33..f8073bff5ea9 100644 --- a/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp @@ -771,7 +771,7 @@ bool isTokAtEndOfExpr(SourceRange ExprSR, Token T, const SourceManager &SM) { return SM.getExpansionLoc(ExprSR.getEnd()) == T.getLocation(); } -/// Returns true if both LhsEpxr and RhsExpr are +/// Returns true if both LhsExpr and RhsExpr are /// macro expressions and they are expanded /// from diff erent macros. static bool areExprsFromDifferentMacros(const Expr *LhsExpr, @@ -863,7 +863,7 @@ void RedundantExpressionCheck::registerMatchers(MatchFinder *Finder) { .bind("nested-duplicates"), this); - // Conditional (trenary) operator with equivalent operands, like (Y ? X : X). + // Conditional (ternary) operator with equivalent operands, like (Y ? X : X). Finder->addMatcher( traverse(TK_AsIs, conditionalOperator(expressionsAreEquivalent(), diff --git a/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp b/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp index a63598fe1129..37a81da557ea 100644 --- a/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp @@ -47,43 +47,43 @@ void ThrowByValueCatchByReferenceCheck::check( } bool ThrowByValueCatchByReferenceCheck::isFunctionParameter( - const DeclRefExpr *declRefExpr) { - return isa<ParmVarDecl>(declRefExpr->getDecl()); + const DeclRefExpr *DeclRefExpr) { + return isa<ParmVarDecl>(DeclRefExpr->getDecl()); } bool ThrowByValueCatchByReferenceCheck::isCatchVariable( - const DeclRefExpr *declRefExpr) { - auto *valueDecl = declRefExpr->getDecl(); - if (auto *varDecl = dyn_cast<VarDecl>(valueDecl)) - return varDecl->isExceptionVariable(); + const DeclRefExpr *DeclRefExpr) { + auto *ValueDecl = DeclRefExpr->getDecl(); + if (auto *VarDecl = dyn_cast<clang::VarDecl>(ValueDecl)) + return VarDecl->isExceptionVariable(); return false; } bool ThrowByValueCatchByReferenceCheck::isFunctionOrCatchVar( - const DeclRefExpr *declRefExpr) { - return isFunctionParameter(declRefExpr) || isCatchVariable(declRefExpr); + const DeclRefExpr *DeclRefExpr) { + return isFunctionParameter(DeclRefExpr) || isCatchVariable(DeclRefExpr); } void ThrowByValueCatchByReferenceCheck::diagnoseThrowLocations( - const CXXThrowExpr *throwExpr) { - if (!throwExpr) + const CXXThrowExpr *ThrowExpr) { + if (!ThrowExpr) return; - auto *subExpr = throwExpr->getSubExpr(); - if (!subExpr) + auto *SubExpr = ThrowExpr->getSubExpr(); + if (!SubExpr) return; - auto qualType = subExpr->getType(); - if (qualType->isPointerType()) { + auto QualType = SubExpr->getType(); + if (QualType->isPointerType()) { // The code is throwing a pointer. - // In case it is strng literal, it is safe and we return. - auto *inner = subExpr->IgnoreParenImpCasts(); - if (isa<StringLiteral>(inner)) + // In case it is string literal, it is safe and we return. + auto *Inner = SubExpr->IgnoreParenImpCasts(); + if (isa<StringLiteral>(Inner)) return; // If it's a variable from a catch statement, we return as well. - auto *declRef = dyn_cast<DeclRefExpr>(inner); - if (declRef && isCatchVariable(declRef)) { + auto *DeclRef = dyn_cast<DeclRefExpr>(Inner); + if (DeclRef && isCatchVariable(DeclRef)) { return; } - diag(subExpr->getBeginLoc(), "throw expression throws a pointer; it should " + diag(SubExpr->getBeginLoc(), "throw expression throws a pointer; it should " "throw a non-pointer value instead"); } // If the throw statement does not throw by pointer then it throws by value @@ -100,61 +100,62 @@ void ThrowByValueCatchByReferenceCheck::diagnoseThrowLocations( // When encountering a CopyOrMoveConstructor: emit message if after casts, // the expression is a LValue if (CheckAnonymousTemporaries) { - bool emit = false; - auto *currentSubExpr = subExpr->IgnoreImpCasts(); - const auto *variableReference = dyn_cast<DeclRefExpr>(currentSubExpr); - const auto *constructorCall = dyn_cast<CXXConstructExpr>(currentSubExpr); + bool Emit = false; + auto *CurrentSubExpr = SubExpr->IgnoreImpCasts(); + const auto *VariableReference = dyn_cast<DeclRefExpr>(CurrentSubExpr); + const auto *ConstructorCall = dyn_cast<CXXConstructExpr>(CurrentSubExpr); // If we have a DeclRefExpr, we flag for emitting a diagnosis message in // case the referenced variable is neither a function parameter nor a // variable declared in the catch statement. - if (variableReference) - emit = !isFunctionOrCatchVar(variableReference); - else if (constructorCall && - constructorCall->getConstructor()->isCopyOrMoveConstructor()) { + if (VariableReference) + Emit = !isFunctionOrCatchVar(VariableReference); + else if (ConstructorCall && + ConstructorCall->getConstructor()->isCopyOrMoveConstructor()) { // If we have a copy / move construction, we emit a diagnosis message if // the object that we copy construct from is neither a function parameter // nor a variable declared in a catch statement - auto argIter = - constructorCall + auto ArgIter = + ConstructorCall ->arg_begin(); // there's only one for copy constructors - auto *currentSubExpr = (*argIter)->IgnoreImpCasts(); - if (currentSubExpr->isLValue()) { - if (auto *tmp = dyn_cast<DeclRefExpr>(currentSubExpr)) - emit = !isFunctionOrCatchVar(tmp); - else if (isa<CallExpr>(currentSubExpr)) - emit = true; + auto *CurrentSubExpr = (*ArgIter)->IgnoreImpCasts(); + if (CurrentSubExpr->isLValue()) { + if (auto *Tmp = dyn_cast<DeclRefExpr>(CurrentSubExpr)) + Emit = !isFunctionOrCatchVar(Tmp); + else if (isa<CallExpr>(CurrentSubExpr)) + Emit = true; } } - if (emit) - diag(subExpr->getBeginLoc(), + if (Emit) + diag(SubExpr->getBeginLoc(), "throw expression should throw anonymous temporary values instead"); } } void ThrowByValueCatchByReferenceCheck::diagnoseCatchLocations( - const CXXCatchStmt *catchStmt, ASTContext &context) { - if (!catchStmt) + const CXXCatchStmt *CatchStmt, ASTContext &Context) { + if (!CatchStmt) return; - auto caughtType = catchStmt->getCaughtType(); - if (caughtType.isNull()) + auto CaughtType = CatchStmt->getCaughtType(); + if (CaughtType.isNull()) return; - auto *varDecl = catchStmt->getExceptionDecl(); - if (const auto *PT = caughtType.getCanonicalType()->getAs<PointerType>()) { - const char *diagMsgCatchReference = "catch handler catches a pointer value; " - "should throw a non-pointer value and " - "catch by reference instead"; + auto *VarDecl = CatchStmt->getExceptionDecl(); + if (const auto *PT = CaughtType.getCanonicalType()->getAs<PointerType>()) { + const char *DiagMsgCatchReference = + "catch handler catches a pointer value; " + "should throw a non-pointer value and " + "catch by reference instead"; // We do not diagnose when catching pointer to strings since we also allow // throwing string literals. if (!PT->getPointeeType()->isAnyCharacterType()) - diag(varDecl->getBeginLoc(), diagMsgCatchReference); - } else if (!caughtType->isReferenceType()) { - const char *diagMsgCatchReference = "catch handler catches by value; " + diag(VarDecl->getBeginLoc(), DiagMsgCatchReference); + } else if (!CaughtType->isReferenceType()) { + const char *DiagMsgCatchReference = "catch handler catches by value; " "should catch by reference instead"; // If it's not a pointer and not a reference then it must be caught "by // value". In this case we should emit a diagnosis message unless the type // is trivial. - if (!caughtType.isTrivialType(context)) { - diag(varDecl->getBeginLoc(), diagMsgCatchReference); + if (!CaughtType.isTrivialType(Context)) { + diag(VarDecl->getBeginLoc(), DiagMsgCatchReference); } else if (WarnOnLargeObject) { // If the type is trivial, then catching it by reference is not dangerous. // However, catching large objects by value decreases the performance. @@ -162,9 +163,9 @@ void ThrowByValueCatchByReferenceCheck::diagnoseCatchLocations( // We can now access `ASTContext` so if `MaxSize` is an extremal value // then set it to the size of `size_t`. if (MaxSize == std::numeric_limits<uint64_t>::max()) - MaxSize = context.getTypeSize(context.getSizeType()); - if (context.getTypeSize(caughtType) > MaxSize) - diag(varDecl->getBeginLoc(), diagMsgCatchReference); + MaxSize = Context.getTypeSize(Context.getSizeType()); + if (Context.getTypeSize(CaughtType) > MaxSize) + diag(VarDecl->getBeginLoc(), DiagMsgCatchReference); } } } diff --git a/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.h b/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.h index 3018fda6a389..de26b6ab5e0a 100644 --- a/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.h +++ b/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.h @@ -37,12 +37,12 @@ class ThrowByValueCatchByReferenceCheck : public ClangTidyCheck { void check(const ast_matchers::MatchFinder::MatchResult &Result) override; private: - void diagnoseThrowLocations(const CXXThrowExpr *throwExpr); - void diagnoseCatchLocations(const CXXCatchStmt *catchStmt, - ASTContext &context); - bool isFunctionParameter(const DeclRefExpr *declRefExpr); - bool isCatchVariable(const DeclRefExpr *declRefExpr); - bool isFunctionOrCatchVar(const DeclRefExpr *declRefExpr); + void diagnoseThrowLocations(const CXXThrowExpr *ThrowExpr); + void diagnoseCatchLocations(const CXXCatchStmt *CatchStmt, + ASTContext &Context); + bool isFunctionParameter(const DeclRefExpr *DeclRefExpr); + bool isCatchVariable(const DeclRefExpr *DeclRefExpr); + bool isFunctionOrCatchVar(const DeclRefExpr *DeclRefExpr); const bool CheckAnonymousTemporaries; const bool WarnOnLargeObject; const uint64_t MaxSizeOptions; // The raw value read from the options. diff --git a/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp b/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp index 63f9f066f194..960eb7b3d670 100644 --- a/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp @@ -334,7 +334,7 @@ static void addPlaceholderArgs(const LambdaProperties &LP, ArrayRef<BindArgument> Args = LP.BindArguments; - auto MaxPlaceholderIt = + const auto *MaxPlaceholderIt = std::max_element(Args.begin(), Args.end(), [](const BindArgument &B1, const BindArgument &B2) { return B1.PlaceHolderIndex < B2.PlaceHolderIndex; diff --git a/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp b/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp index 5acbe9971416..3caaa3c876ab 100644 --- a/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp @@ -182,7 +182,7 @@ void PassByValueCheck::check(const MatchFinder::MatchResult &Result) { if (!paramReferredExactlyOnce(Ctor, ParamDecl)) return; - // If the parameter is trivial to copy, don't move it. Moving a trivivally + // If the parameter is trivial to copy, don't move it. Moving a trivially // copyable type will cause a problem with performance-move-const-arg if (ParamDecl->getType().getNonReferenceType().isTriviallyCopyableType( *Result.Context)) diff --git a/clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.h b/clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.h index 8288c7e47d35..892723b9aaa4 100644 --- a/clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.h +++ b/clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.h @@ -24,7 +24,7 @@ namespace modernize { /// operations do not 'copy' the resource but they 'steal' it. /// `std::unique_ptr` uses move semantics instead, which makes the intent of /// transferring the resource explicit. This diff erence between the two smart -/// pointers requeres to wrap the copy-ctor and assign-operator with +/// pointers requires wrapping the copy-ctor and assign-operator with /// `std::move()`. /// /// For example, given: diff --git a/clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp b/clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp index 9752fd0a9e95..438fd4882b7f 100644 --- a/clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp @@ -32,7 +32,7 @@ class ReplaceDisallowCopyAndAssignMacroCallbacks : public PPCallbacks { return; if (Info->getName() != Check.getMacroName()) return; - // The first argument to the DISALLOW_COPY_AND_ASSIGN macro is exptected to + // The first argument to the DISALLOW_COPY_AND_ASSIGN macro is expected to // be the class name. const Token *ClassNameTok = Args->getUnexpArgument(0); if (Args->ArgNeedsPreexpansion(ClassNameTok, PP)) diff --git a/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.h b/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.h index 143cba4da7d6..0c7f73ff8537 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.h +++ b/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.h @@ -19,7 +19,7 @@ class UseNullptrCheck : public ClangTidyCheck { public: UseNullptrCheck(StringRef Name, ClangTidyContext *Context); bool isLanguageVersionSupported(const LangOptions &LangOpts) const override { - // FIXME this should be CPlusCplus11 but that causes test cases to + // FIXME this should be CPlusPlus11 but that causes test cases to // erroneously fail. return LangOpts.CPlusPlus; } diff --git a/clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp index 510e17f58c81..63c6f6b8e7aa 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp @@ -172,7 +172,7 @@ void UseOverrideCheck::check(const MatchFinder::MatchResult &Result) { // same line as the declaration if the beginning brace for the start of // the body falls on the next line. ReplacementText = " " + OverrideSpelling; - auto LastTokenIter = std::prev(Tokens.end()); + auto *LastTokenIter = std::prev(Tokens.end()); // When try statement is used instead of compound statement as // method body - insert override keyword before it. if (LastTokenIter->is(tok::kw_try)) diff --git a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp index 72d918822270..d8d9e28d598d 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp @@ -78,7 +78,7 @@ struct UnqualNameVisitor : public RecursiveASTVisitor<UnqualNameVisitor> { return RecursiveASTVisitor<UnqualNameVisitor>::TraverseTypeLoc(TL); } - // Replace the base method in order to call ower own + // Replace the base method in order to call our own // TraverseTypeLoc(). bool TraverseQualifiedTypeLoc(QualifiedTypeLoc TL) { return TraverseTypeLoc(TL.getUnqualifiedLoc()); @@ -172,8 +172,8 @@ static llvm::Optional<ClassifiedToken> classifyToken(const FunctionDecl &F, Preprocessor &PP, Token Tok) { ClassifiedToken CT; CT.T = Tok; - CT.isQualifier = true; - CT.isSpecifier = true; + CT.IsQualifier = true; + CT.IsSpecifier = true; bool ContainsQualifiers = false; bool ContainsSpecifiers = false; bool ContainsSomethingElse = false; @@ -193,8 +193,8 @@ classifyToken(const FunctionDecl &F, Preprocessor &PP, Token Tok) { bool Qual = isCvr(T); bool Spec = isSpecifier(T); - CT.isQualifier &= Qual; - CT.isSpecifier &= Spec; + CT.IsQualifier &= Qual; + CT.IsSpecifier &= Spec; ContainsQualifiers |= Qual; ContainsSpecifiers |= Spec; ContainsSomethingElse |= !Qual && !Spec; @@ -329,7 +329,7 @@ SourceRange UseTrailingReturnTypeCheck::findReturnTypeAndCVSourceRange( !ExtendedLeft) { assert(I <= size_t(std::numeric_limits<int>::max()) && "Integer overflow detected"); - for (int J = static_cast<int>(I) - 1; J >= 0 && Tokens[J].isQualifier; + for (int J = static_cast<int>(I) - 1; J >= 0 && Tokens[J].IsQualifier; J--) ReturnTypeRange.setBegin(Tokens[J].T.getLocation()); ExtendedLeft = true; @@ -337,7 +337,7 @@ SourceRange UseTrailingReturnTypeCheck::findReturnTypeAndCVSourceRange( // If we found the end of the return type, include right qualifiers. if (SM.isBeforeInTranslationUnit(ReturnTypeRange.getEnd(), Tokens[I].T.getLocation())) { - for (size_t J = I; J < Tokens.size() && Tokens[J].isQualifier; J++) + for (size_t J = I; J < Tokens.size() && Tokens[J].IsQualifier; J++) ReturnTypeRange.setEnd(Tokens[J].T.getLocation()); break; } @@ -380,7 +380,7 @@ void UseTrailingReturnTypeCheck::keepSpecifiers( SM.isBeforeInTranslationUnit(ReturnTypeCVRange.getEnd(), CT.T.getLocation())) continue; - if (!CT.isSpecifier) + if (!CT.IsSpecifier) continue; // Add the token to 'auto' and remove it from the return type, including diff --git a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.h b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.h index d72e8eb04c9d..dd32e4383329 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.h +++ b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.h @@ -18,8 +18,8 @@ namespace modernize { struct ClassifiedToken { Token T; - bool isQualifier; - bool isSpecifier; + bool IsQualifier; + bool IsSpecifier; }; /// Rewrites function signatures to use a trailing return type. diff --git a/clang-tools-extra/clang-tidy/performance/ImplicitConversionInLoopCheck.cpp b/clang-tools-extra/clang-tidy/performance/ImplicitConversionInLoopCheck.cpp index 738e376744e3..61e8366b007a 100644 --- a/clang-tools-extra/clang-tidy/performance/ImplicitConversionInLoopCheck.cpp +++ b/clang-tools-extra/clang-tidy/performance/ImplicitConversionInLoopCheck.cpp @@ -21,7 +21,7 @@ namespace tidy { namespace performance { // Checks if the stmt is a ImplicitCastExpr with a CastKind that is not a NoOp. -// The subtelty is that in some cases (user defined conversions), we can +// The subtlety is that in some cases (user defined conversions), we can // get to ImplicitCastExpr inside each other, with the outer one a NoOp. In this // case we skip the first cast expr. static bool isNonTrivialImplicitCast(const Stmt *ST) { @@ -82,12 +82,12 @@ void ImplicitConversionInLoopCheck::check( // is a reference. This situation is fine (it probably produces the same // code at the end). if (isNonTrivialImplicitCast(Materialized->getSubExpr())) - ReportAndFix(Result.Context, VD, OperatorCall); + reportAndFix(Result.Context, VD, OperatorCall); } -void ImplicitConversionInLoopCheck::ReportAndFix( - const ASTContext *Context, const VarDecl *VD, - const Expr *OperatorCall) { +void ImplicitConversionInLoopCheck::reportAndFix(const ASTContext *Context, + const VarDecl *VD, + const Expr *OperatorCall) { // We only match on const ref, so we should print a const ref version of the // type. QualType ConstType = OperatorCall->getType().withConst(); diff --git a/clang-tools-extra/clang-tidy/performance/ImplicitConversionInLoopCheck.h b/clang-tools-extra/clang-tidy/performance/ImplicitConversionInLoopCheck.h index 4b271366f0f6..b95d75e98b3a 100644 --- a/clang-tools-extra/clang-tidy/performance/ImplicitConversionInLoopCheck.h +++ b/clang-tools-extra/clang-tidy/performance/ImplicitConversionInLoopCheck.h @@ -29,7 +29,7 @@ class ImplicitConversionInLoopCheck : public ClangTidyCheck { void check(const ast_matchers::MatchFinder::MatchResult &Result) override; private: - void ReportAndFix(const ASTContext *Context, const VarDecl *VD, + void reportAndFix(const ASTContext *Context, const VarDecl *VD, const Expr *OperatorCall); }; diff --git a/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp b/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp index f7c5112d22ea..a12d403d6ba0 100644 --- a/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp +++ b/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp @@ -84,7 +84,7 @@ void InefficientVectorOperationCheck::storeOptions( Options.store(Opts, "EnableProto", EnableProto); } -void InefficientVectorOperationCheck::AddMatcher( +void InefficientVectorOperationCheck::addMatcher( const DeclarationMatcher &TargetRecordDecl, StringRef VarDeclName, StringRef VarDeclStmtName, const DeclarationMatcher &AppendMethodDecl, StringRef AppendCallName, MatchFinder *Finder) { @@ -156,7 +156,7 @@ void InefficientVectorOperationCheck::registerMatchers(MatchFinder *Finder) { VectorLikeClasses.begin(), VectorLikeClasses.end()))); const auto AppendMethodDecl = cxxMethodDecl(hasAnyName("push_back", "emplace_back")); - AddMatcher(VectorDecl, VectorVarDeclName, VectorVarDeclStmtName, + addMatcher(VectorDecl, VectorVarDeclName, VectorVarDeclStmtName, AppendMethodDecl, PushBackOrEmplaceBackCallName, Finder); if (EnableProto) { @@ -168,7 +168,7 @@ void InefficientVectorOperationCheck::registerMatchers(MatchFinder *Finder) { // with "add_". So we exclude const methods. const auto AddFieldMethodDecl = cxxMethodDecl(matchesName("::add_"), unless(isConst())); - AddMatcher(ProtoDecl, ProtoVarDeclName, ProtoVarDeclStmtName, + addMatcher(ProtoDecl, ProtoVarDeclName, ProtoVarDeclStmtName, AddFieldMethodDecl, ProtoAddFieldCallName, Finder); } } diff --git a/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.h b/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.h index 533b30dc32b0..cebe199a5acd 100644 --- a/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.h +++ b/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.h @@ -34,7 +34,7 @@ class InefficientVectorOperationCheck : public ClangTidyCheck { void storeOptions(ClangTidyOptions::OptionMap &Opts) override; private: - void AddMatcher(const ast_matchers::DeclarationMatcher &TargetRecordDecl, + void addMatcher(const ast_matchers::DeclarationMatcher &TargetRecordDecl, StringRef VarDeclName, StringRef VarDeclStmtName, const ast_matchers::DeclarationMatcher &AppendMethodDecl, StringRef AppendCallName, ast_matchers::MatchFinder *Finder); diff --git a/clang-tools-extra/clang-tidy/plugin/ClangTidyPlugin.cpp b/clang-tools-extra/clang-tidy/plugin/ClangTidyPlugin.cpp index b8367d6384f2..01402f1d5f8e 100644 --- a/clang-tools-extra/clang-tidy/plugin/ClangTidyPlugin.cpp +++ b/clang-tools-extra/clang-tidy/plugin/ClangTidyPlugin.cpp @@ -48,7 +48,7 @@ class ClangTidyPluginAction : public PluginASTAction { // Create the AST consumer. ClangTidyASTConsumerFactory Factory(*Context); std::vector<std::unique_ptr<ASTConsumer>> Vec; - Vec.push_back(Factory.CreateASTConsumer(Compiler, File)); + Vec.push_back(Factory.createASTConsumer(Compiler, File)); return std::make_unique<WrapConsumer>( std::move(Context), std::move(DiagEngine), std::move(Vec)); diff --git a/clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.h b/clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.h index 3a5fb08ee93b..3f65e6048724 100644 --- a/clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.h +++ b/clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.h @@ -23,8 +23,8 @@ namespace readability { class ConstReturnTypeCheck : public ClangTidyCheck { public: using ClangTidyCheck::ClangTidyCheck; - void registerMatchers(ast_matchers::MatchFinder* finder) override; - void check(const ast_matchers::MatchFinder::MatchResult& result) override; + void registerMatchers(ast_matchers::MatchFinder *Finder) override; + void check(const ast_matchers::MatchFinder::MatchResult &Result) override; }; } // namespace readability diff --git a/clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.h b/clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.h index 0f0f8233f5d8..e11bd627614f 100644 --- a/clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.h +++ b/clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.h @@ -20,8 +20,8 @@ namespace readability { /// This only replaces the case where the offset being accessed through the /// subscript operation is a known constant 0. This avoids a potential invalid /// memory access when the container is empty. Cases where the constant is not -/// explictly zero can be addressed through the clang static analyzer, and those -/// which cannot be statically identified can be caught using UBSan. +/// explicitly zero can be addressed through the clang static analyzer, and +/// those which cannot be statically identified can be caught using UBSan. class ContainerDataPointerCheck : public ClangTidyCheck { public: ContainerDataPointerCheck(StringRef Name, ClangTidyContext *Context); diff --git a/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp b/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp index a1d8064d23a0..548fed9a47c3 100644 --- a/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp @@ -90,7 +90,7 @@ AST_MATCHER(CXXConstructExpr, isDefaultConstruction) { namespace tidy { namespace readability { -using utils::IsBinaryOrTernary; +using utils::isBinaryOrTernary; ContainerSizeEmptyCheck::ContainerSizeEmptyCheck(StringRef Name, ClangTidyContext *Context) @@ -191,7 +191,7 @@ void ContainerSizeEmptyCheck::check(const MatchFinder::MatchResult &Result) { std::string ReplacementText = std::string( Lexer::getSourceText(CharSourceRange::getTokenRange(E->getSourceRange()), *Result.SourceManager, getLangOpts())); - if (IsBinaryOrTernary(E) || isa<UnaryOperator>(E)) { + if (isBinaryOrTernary(E) || isa<UnaryOperator>(E)) { ReplacementText = "(" + ReplacementText + ")"; } if (E->getType()->isPointerType()) diff --git a/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp b/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp index 9f53a5578b0a..c27733c04083 100644 --- a/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp @@ -86,7 +86,7 @@ struct CognitiveComplexity final { }; // The helper struct used to record one increment occurrence, with all the - // details nessesary. + // details necessary. struct Detail { const SourceLocation Loc; // What caused the increment? const unsigned short Nesting; // How deeply nested is Loc located? diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp index 0ff0708adc4a..d275b475f97c 100644 --- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp @@ -1381,7 +1381,7 @@ IdentifierNamingCheck::getFailureInfo( } llvm::Optional<RenamerClangTidyCheck::FailureInfo> -IdentifierNamingCheck::GetDeclFailureInfo(const NamedDecl *Decl, +IdentifierNamingCheck::getDeclFailureInfo(const NamedDecl *Decl, const SourceManager &SM) const { SourceLocation Loc = Decl->getLocation(); const FileStyle &FileStyle = getStyleForFile(SM.getFilename(Loc)); @@ -1397,7 +1397,7 @@ IdentifierNamingCheck::GetDeclFailureInfo(const NamedDecl *Decl, } llvm::Optional<RenamerClangTidyCheck::FailureInfo> -IdentifierNamingCheck::GetMacroFailureInfo(const Token &MacroNameTok, +IdentifierNamingCheck::getMacroFailureInfo(const Token &MacroNameTok, const SourceManager &SM) const { SourceLocation Loc = MacroNameTok.getLocation(); const FileStyle &Style = getStyleForFile(SM.getFilename(Loc)); @@ -1410,7 +1410,7 @@ IdentifierNamingCheck::GetMacroFailureInfo(const Token &MacroNameTok, } RenamerClangTidyCheck::DiagInfo -IdentifierNamingCheck::GetDiagInfo(const NamingCheckId &ID, +IdentifierNamingCheck::getDiagInfo(const NamingCheckId &ID, const NamingCheckFailure &Failure) const { return DiagInfo{"invalid case style for %0 '%1'", [&](DiagnosticBuilder &Diag) { diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h index da303d785b8a..a1621961986e 100644 --- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h +++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h @@ -186,12 +186,12 @@ class IdentifierNamingCheck final : public RenamerClangTidyCheck { private: llvm::Optional<FailureInfo> - GetDeclFailureInfo(const NamedDecl *Decl, + getDeclFailureInfo(const NamedDecl *Decl, const SourceManager &SM) const override; llvm::Optional<FailureInfo> - GetMacroFailureInfo(const Token &MacroNameTok, + getMacroFailureInfo(const Token &MacroNameTok, const SourceManager &SM) const override; - DiagInfo GetDiagInfo(const NamingCheckId &ID, + DiagInfo getDiagInfo(const NamingCheckId &ID, const NamingCheckFailure &Failure) const override; const FileStyle &getStyleForFile(StringRef FileName) const; diff --git a/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp b/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp index 1fcd1b76af85..2ef0150cccca 100644 --- a/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp @@ -104,8 +104,8 @@ findDifferingParamsInDeclaration(const FunctionDecl *ParameterSourceDeclaration, bool Strict) { DifferingParamsContainer DifferingParams; - auto SourceParamIt = ParameterSourceDeclaration->param_begin(); - auto OtherParamIt = OtherDeclaration->param_begin(); + const auto *SourceParamIt = ParameterSourceDeclaration->param_begin(); + const auto *OtherParamIt = OtherDeclaration->param_begin(); while (SourceParamIt != ParameterSourceDeclaration->param_end() && OtherParamIt != OtherDeclaration->param_end()) { diff --git a/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp b/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp index f2838cd0b984..95380069f527 100644 --- a/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp @@ -226,7 +226,7 @@ void QualifiedAutoCheck::check(const MatchFinder::MatchResult &Result) { if (!isPointerConst(Var->getType())) return; // Pointer isn't const, no need to add const qualifier. if (!isAutoPointerConst(Var->getType())) - return; // Const isnt wrapped in the auto type, so must be declared + return; // Const isn't wrapped in the auto type, so must be declared // explicitly. if (Var->getType().isLocalConstQualified()) { @@ -267,7 +267,7 @@ void QualifiedAutoCheck::check(const MatchFinder::MatchResult &Result) { if (!isPointerConst(Var->getType())) return; // Pointer isn't const, no need to add const qualifier. if (!isAutoPointerConst(Var->getType())) - // Const isnt wrapped in the auto type, so must be declared explicitly. + // Const isn't wrapped in the auto type, so must be declared explicitly. return; if (llvm::Optional<SourceRange> TypeSpec = diff --git a/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp b/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp index dae750385641..b226e2522115 100644 --- a/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp +++ b/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp @@ -24,7 +24,7 @@ const FunctionDecl *getSurroundingFunction(ASTContext &Context, Statement, Context)); } -bool IsBinaryOrTernary(const Expr *E) { +bool isBinaryOrTernary(const Expr *E) { const Expr *EBase = E->IgnoreImpCasts(); if (isa<BinaryOperator>(EBase) || isa<ConditionalOperator>(EBase)) { return true; diff --git a/clang-tools-extra/clang-tidy/utils/ASTUtils.h b/clang-tools-extra/clang-tidy/utils/ASTUtils.h index ad2a055f5fb9..b84808e09ec7 100644 --- a/clang-tools-extra/clang-tidy/utils/ASTUtils.h +++ b/clang-tools-extra/clang-tidy/utils/ASTUtils.h @@ -18,7 +18,7 @@ namespace utils { const FunctionDecl *getSurroundingFunction(ASTContext &Context, const Stmt &Statement); // Determine whether Expr is a Binary or Ternary expression. -bool IsBinaryOrTernary(const Expr *E); +bool isBinaryOrTernary(const Expr *E); /// Checks whether a macro flag is present in the given argument. Only considers /// cases of single match or match in a binary OR expression. For example, diff --git a/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp b/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp index 38122d5420ac..2df046148696 100644 --- a/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp +++ b/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp @@ -48,7 +48,7 @@ constReferenceDeclRefExprs(const VarDecl &VarDecl, const Stmt &Stmt, declRefExpr(to(varDecl(equalsNode(&VarDecl)))).bind("declRef"); auto ConstMethodCallee = callee(cxxMethodDecl(isConst())); // Match method call expressions where the variable is referenced as the this - // implicit object argument and opertor call expression for member operators + // implicit object argument and operator call expression for member operators // where the variable is the 0-th argument. auto Matches = match( findAll(expr(anyOf(cxxMemberCallExpr(ConstMethodCallee, on(DeclRefToVar)), diff --git a/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp b/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp index 5fc6020d4265..6f3eed49831f 100644 --- a/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp +++ b/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp @@ -19,7 +19,7 @@ class IncludeInserterCallback : public PPCallbacks { public: explicit IncludeInserterCallback(IncludeInserter *Inserter) : Inserter(Inserter) {} - // Implements PPCallbacks::InclusionDerective(). Records the names and source + // Implements PPCallbacks::InclusionDirective(). Records the names and source // locations of the inclusions in the main source file being processed. void InclusionDirective(SourceLocation HashLocation, const Token &IncludeToken, StringRef FileNameRef, @@ -76,7 +76,7 @@ IncludeInserter::createIncludeInsertion(FileID FileID, llvm::StringRef Header) { if (!InsertedHeaders[FileID].insert(Header).second) return llvm::None; - return getOrCreate(FileID).CreateIncludeInsertion(Header, IsAngled); + return getOrCreate(FileID).createIncludeInsertion(Header, IsAngled); } llvm::Optional<FixItHint> @@ -92,7 +92,7 @@ void IncludeInserter::addInclude(StringRef FileName, bool IsAngled, assert(SourceMgr && "SourceMgr shouldn't be null; did you remember to call " "registerPreprocessor()?"); FileID FileID = SourceMgr->getFileID(HashLocation); - getOrCreate(FileID).AddInclude(FileName, IsAngled, HashLocation, EndLocation); + getOrCreate(FileID).addInclude(FileName, IsAngled, HashLocation, EndLocation); } } // namespace utils diff --git a/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp b/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp index de75148d127a..fbc1dc6d52a0 100644 --- a/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp +++ b/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp @@ -129,7 +129,7 @@ IncludeSorter::IncludeSorter(const SourceManager *SourceMgr, : SourceMgr(SourceMgr), Style(Style), CurrentFileID(FileID), CanonicalFile(makeCanonicalName(FileName, Style)) {} -void IncludeSorter::AddInclude(StringRef FileName, bool IsAngled, +void IncludeSorter::addInclude(StringRef FileName, bool IsAngled, SourceLocation HashLocation, SourceLocation EndLocation) { int Offset = findNextLine(SourceMgr->getCharacterData(EndLocation)); @@ -150,7 +150,7 @@ void IncludeSorter::AddInclude(StringRef FileName, bool IsAngled, IncludeBucket[Kind].push_back(FileName.str()); } -Optional<FixItHint> IncludeSorter::CreateIncludeInsertion(StringRef FileName, +Optional<FixItHint> IncludeSorter::createIncludeInsertion(StringRef FileName, bool IsAngled) { std::string IncludeStmt; if (Style == IncludeStyle::IS_Google_ObjC) { diff --git a/clang-tools-extra/clang-tidy/utils/IncludeSorter.h b/clang-tools-extra/clang-tidy/utils/IncludeSorter.h index a8cf18ca8625..ecde60de4f9e 100644 --- a/clang-tools-extra/clang-tidy/utils/IncludeSorter.h +++ b/clang-tools-extra/clang-tidy/utils/IncludeSorter.h @@ -41,12 +41,12 @@ class IncludeSorter { StringRef FileName, IncludeStyle Style); /// Adds the given include directive to the sorter. - void AddInclude(StringRef FileName, bool IsAngled, + void addInclude(StringRef FileName, bool IsAngled, SourceLocation HashLocation, SourceLocation EndLocation); /// Creates a quoted inclusion directive in the right sort order. Returns None /// on error or if header inclusion directive for header already exists. - Optional<FixItHint> CreateIncludeInsertion(StringRef FileName, bool IsAngled); + Optional<FixItHint> createIncludeInsertion(StringRef FileName, bool IsAngled); private: typedef SmallVector<SourceRange, 1> SourceRangeVector; diff --git a/clang-tools-extra/clang-tidy/utils/LexerUtils.cpp b/clang-tools-extra/clang-tidy/utils/LexerUtils.cpp index 88828f72e6bb..f769db8840f7 100644 --- a/clang-tools-extra/clang-tidy/utils/LexerUtils.cpp +++ b/clang-tools-extra/clang-tidy/utils/LexerUtils.cpp @@ -178,7 +178,7 @@ static SourceLocation getSemicolonAfterStmtEndLoc(const SourceLocation &EndLoc, // All macro issues are simply resolved by ensuring it's a semicolon. if (NextTok && NextTok->is(tok::TokenKind::semi)) { // Ideally this would return `F` with spelling location `;` (NextTok) - // following the examle above. For now simply return NextTok location. + // following the example above. For now simply return NextTok location. return NextTok->getLocation(); } diff --git a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp index d719f847f50d..a0dcca7f9973 100644 --- a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp +++ b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp @@ -23,7 +23,7 @@ using namespace clang::ast_matchers; namespace llvm { -/// Specialisation of DenseMapInfo to allow NamingCheckId objects in DenseMaps +/// Specialization of DenseMapInfo to allow NamingCheckId objects in DenseMaps template <> struct DenseMapInfo<clang::tidy::RenamerClangTidyCheck::NamingCheckId> { using NamingCheckId = clang::tidy::RenamerClangTidyCheck::NamingCheckId; @@ -176,7 +176,7 @@ void RenamerClangTidyCheck::addUsage( if (!Failure.RawUsageLocs.insert(FixLocation).second) return; - if (!Failure.ShouldFix()) + if (!Failure.shouldFix()) return; if (SourceMgr && SourceMgr->isWrittenInScratchSpace(FixLocation)) @@ -265,7 +265,7 @@ NameLookup findDeclInBases(const CXXRecordDecl &Parent, StringRef DeclName, } else return NameLookup(llvm::None); // Propagate multiple resolution back up. } - return NameLookup(Found); // If nullptr, decl wasnt found. + return NameLookup(Found); // If nullptr, decl wasn't found. } void RenamerClangTidyCheck::check(const MatchFinder::MatchResult &Result) { @@ -446,7 +446,7 @@ void RenamerClangTidyCheck::check(const MatchFinder::MatchResult &Result) { return; Optional<FailureInfo> MaybeFailure = - GetDeclFailureInfo(Decl, *Result.SourceManager); + getDeclFailureInfo(Decl, *Result.SourceManager); if (!MaybeFailure) return; FailureInfo &Info = *MaybeFailure; @@ -477,7 +477,7 @@ void RenamerClangTidyCheck::checkMacro(SourceManager &SourceMgr, const Token &MacroNameTok, const MacroInfo *MI) { Optional<FailureInfo> MaybeFailure = - GetMacroFailureInfo(MacroNameTok, SourceMgr); + getMacroFailureInfo(MacroNameTok, SourceMgr); if (!MaybeFailure) return; FailureInfo &Info = *MaybeFailure; @@ -532,14 +532,14 @@ void RenamerClangTidyCheck::onEndOfTranslationUnit() { if (Failure.Info.KindName.empty()) continue; - if (Failure.ShouldNotify()) { - auto DiagInfo = GetDiagInfo(Decl, Failure); + if (Failure.shouldNotify()) { + auto DiagInfo = getDiagInfo(Decl, Failure); auto Diag = diag(Decl.first, DiagInfo.Text + getDiagnosticSuffix(Failure.FixStatus, Failure.Info.Fixup)); DiagInfo.ApplyArgs(Diag); - if (Failure.ShouldFix()) { + if (Failure.shouldFix()) { for (const auto &Loc : Failure.RawUsageLocs) { // We assume that the identifier name is made of one token only. This // is always the case as we ignore usages in macros that could build diff --git a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h index fd5b32075cbe..def04c917bbc 100644 --- a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h +++ b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h @@ -1,4 +1,4 @@ -//===--- RenamderClangTidyCheck.h - clang-tidy ------------------*- C++ -*-===// +//===--- RenamerClangTidyCheck.h - clang-tidy -------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -32,7 +32,7 @@ class RenamerClangTidyCheck : public ClangTidyCheck { /// Derived classes should not implement any matching logic themselves; this /// class will do the matching and call the derived class' - /// GetDeclFailureInfo() and GetMacroFailureInfo() for determining whether a + /// getDeclFailureInfo() and getMacroFailureInfo() for determining whether a /// given identifier passes or fails the check. void registerMatchers(ast_matchers::MatchFinder *Finder) override final; void @@ -87,11 +87,11 @@ class RenamerClangTidyCheck : public ClangTidyCheck { /// /// e.g.: if the identifier was used or declared within a macro we won't /// offer a fixup for safety reasons. - bool ShouldFix() const { + bool shouldFix() const { return FixStatus == ShouldFixStatus::ShouldFix && !Info.Fixup.empty(); } - bool ShouldNotify() const { + bool shouldNotify() const { return FixStatus < ShouldFixStatus::IgnoreFailureThreshold; } @@ -109,7 +109,7 @@ class RenamerClangTidyCheck : public ClangTidyCheck { llvm::DenseMap<NamingCheckId, NamingCheckFailure>; /// Check Macros for style violations. - void checkMacro(SourceManager &sourceMgr, const Token &MacroNameTok, + void checkMacro(SourceManager &SourceMgr, const Token &MacroNameTok, const MacroInfo *MI); /// Add a usage of a macro if it already has a violation. @@ -126,13 +126,13 @@ class RenamerClangTidyCheck : public ClangTidyCheck { /// Overridden by derived classes, returns information about if and how a Decl /// failed the check. A 'None' result means the Decl did not fail the check. virtual llvm::Optional<FailureInfo> - GetDeclFailureInfo(const NamedDecl *Decl, const SourceManager &SM) const = 0; + getDeclFailureInfo(const NamedDecl *Decl, const SourceManager &SM) const = 0; /// Overridden by derived classes, returns information about if and how a /// macro failed the check. A 'None' result means the macro did not fail the /// check. virtual llvm::Optional<FailureInfo> - GetMacroFailureInfo(const Token &MacroNameTok, + getMacroFailureInfo(const Token &MacroNameTok, const SourceManager &SM) const = 0; /// Represents customized diagnostic text and how arguments should be applied. @@ -151,7 +151,7 @@ class RenamerClangTidyCheck : public ClangTidyCheck { /// that should be emitted for the given failure. The base class will then /// further customize the diagnostic by adding info about whether the fix-it /// can be automatically applied or not. - virtual DiagInfo GetDiagInfo(const NamingCheckId &ID, + virtual DiagInfo getDiagInfo(const NamingCheckId &ID, const NamingCheckFailure &Failure) const = 0; private: diff --git a/clang-tools-extra/clang-tidy/utils/TypeTraits.h b/clang-tools-extra/clang-tidy/utils/TypeTraits.h index f4d3455e9e13..7e6b795e8127 100644 --- a/clang-tools-extra/clang-tidy/utils/TypeTraits.h +++ b/clang-tools-extra/clang-tidy/utils/TypeTraits.h @@ -37,7 +37,7 @@ bool hasNonTrivialMoveConstructor(QualType Type); /// Return true if `Type` has a non-trivial move assignment operator. bool hasNonTrivialMoveAssignment(QualType Type); -} // type_traits +} // namespace type_traits } // namespace utils } // namespace tidy } // namespace clang _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits