alexfh updated this revision to Diff 319979.
alexfh added a comment.

Manually cleaned up suboptimal fixes.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95614/new/

https://reviews.llvm.org/D95614

Files:
  clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SpuriouslyWakeUpFunctionsCheck.cpp
  clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
  clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
  clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp
  clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
  
clang-tools-extra/clang-tidy/performance/InefficientStringConcatenationCheck.cpp
  clang-tools-extra/clang-tidy/plugin/ClangTidyPlugin.cpp
  
clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
  clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp
  clang-tools-extra/clang-tidy/utils/ASTUtils.cpp

Index: clang-tools-extra/clang-tidy/utils/ASTUtils.cpp
===================================================================
--- clang-tools-extra/clang-tidy/utils/ASTUtils.cpp
+++ clang-tools-extra/clang-tidy/utils/ASTUtils.cpp
@@ -26,13 +26,11 @@
 
 bool IsBinaryOrTernary(const Expr *E) {
   const Expr *EBase = E->IgnoreImpCasts();
-  if (clang::isa<clang::BinaryOperator>(EBase) ||
-      clang::isa<clang::ConditionalOperator>(EBase)) {
+  if (isa<BinaryOperator>(EBase) || isa<ConditionalOperator>(EBase)) {
     return true;
   }
 
-  if (const auto *Operator =
-          clang::dyn_cast<clang::CXXOperatorCallExpr>(EBase)) {
+  if (const auto *Operator = dyn_cast<CXXOperatorCallExpr>(EBase)) {
     return Operator->isInfixBinaryOp();
   }
 
@@ -56,7 +54,7 @@
   }
   // If it's a binary OR operation.
   if (const auto *BO = dyn_cast<BinaryOperator>(Flags))
-    if (BO->getOpcode() == clang::BinaryOperatorKind::BO_Or)
+    if (BO->getOpcode() == BinaryOperatorKind::BO_Or)
       return exprHasBitFlagWithSpelling(BO->getLHS()->IgnoreParenCasts(), SM,
                                         LangOpts, FlagName) ||
              exprHasBitFlagWithSpelling(BO->getRHS()->IgnoreParenCasts(), SM,
Index: clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp
@@ -68,7 +68,7 @@
   bool MultiVar = false;
   if (const auto *VD = dyn_cast<VarDecl>(D)) {
     // Is this a multivariable declaration?
-    for (auto *const Other : VD->getDeclContext()->decls()) {
+    for (const auto *Other : VD->getDeclContext()->decls()) {
       if (Other != D && Other->getBeginLoc() == VD->getBeginLoc()) {
         MultiVar = true;
         break;
Index: clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
@@ -105,8 +105,8 @@
                                  bool Strict) {
   DifferingParamsContainer DifferingParams;
 
-  const auto *SourceParamIt = ParameterSourceDeclaration->param_begin();
-  const auto *OtherParamIt = OtherDeclaration->param_begin();
+  auto SourceParamIt = ParameterSourceDeclaration->param_begin();
+  auto OtherParamIt = OtherDeclaration->param_begin();
 
   while (SourceParamIt != ParameterSourceDeclaration->param_end() &&
          OtherParamIt != OtherDeclaration->param_end()) {
Index: clang-tools-extra/clang-tidy/plugin/ClangTidyPlugin.cpp
===================================================================
--- clang-tools-extra/clang-tidy/plugin/ClangTidyPlugin.cpp
+++ clang-tools-extra/clang-tidy/plugin/ClangTidyPlugin.cpp
@@ -39,9 +39,8 @@
   std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &Compiler,
                                                  StringRef File) override {
     // Create and set diagnostics engine
-    auto *ExternalDiagEngine = &Compiler.getDiagnostics();
     auto *DiagConsumer =
-        new ClangTidyDiagnosticConsumer(*Context, ExternalDiagEngine);
+        new ClangTidyDiagnosticConsumer(*Context, &Compiler.getDiagnostics());
     auto DiagEngine = std::make_unique<DiagnosticsEngine>(
         new DiagnosticIDs, new DiagnosticOptions, DiagConsumer);
     Context->setDiagnosticsEngine(DiagEngine.get());
Index: clang-tools-extra/clang-tidy/performance/InefficientStringConcatenationCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/performance/InefficientStringConcatenationCheck.cpp
+++ clang-tools-extra/clang-tidy/performance/InefficientStringConcatenationCheck.cpp
@@ -69,7 +69,7 @@
   const auto *LhsStr = Result.Nodes.getNodeAs<DeclRefExpr>("lhsStr");
   const auto *PlusOperator =
       Result.Nodes.getNodeAs<CXXOperatorCallExpr>("plusOperator");
-  const auto *const DiagMsg =
+  const char *DiagMsg =
       "string concatenation results in allocation of unnecessary temporary "
       "strings; consider using 'operator+=' or 'string::append()' instead";
 
Index: clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
@@ -58,7 +58,7 @@
     return;
   }
 
-  auto PrintPolicy = PrintingPolicy(getLangOpts());
+  PrintingPolicy PrintPolicy(getLangOpts());
   PrintPolicy.SuppressScope = true;
   PrintPolicy.ConstantArraySizeAsWritten = true;
   PrintPolicy.UseVoidForZeroParams = false;
Index: clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
@@ -172,7 +172,7 @@
       // 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))
Index: clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp
@@ -79,7 +79,6 @@
         MatchedCallExpr->getRParenLoc(),
         ", std::mt19937(std::random_device()())");
     return DiagL;
-   
   }();
 
   std::string NewName = "shuffle";
Index: clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -387,18 +387,18 @@
         //   std::make_smart_ptr<S>(std::initializer_list<int>({}));
         //   std::make_smart_ptr<S2>(S{1, 2}, 3);
         return false;
-      } // Direct initialization with ordinary constructors.
-        //   struct S { S(int x); S(); };
-        //   smart_ptr<S>(new S{5});
-        //   smart_ptr<S>(new S{}); // use default constructor
-        // The arguments in the initialization list are going to be forwarded to
-        // the constructor, so this has to be replaced with:
-        //   std::make_smart_ptr<S>(5);
-        //   std::make_smart_ptr<S>();
-        InitRange = SourceRange(
-            NewConstruct->getParenOrBraceRange().getBegin().getLocWithOffset(1),
-            NewConstruct->getParenOrBraceRange().getEnd().getLocWithOffset(-1));
-
+      }
+      // Direct initialization with ordinary constructors.
+      //   struct S { S(int x); S(); };
+      //   smart_ptr<S>(new S{5});
+      //   smart_ptr<S>(new S{}); // use default constructor
+      // The arguments in the initialization list are going to be forwarded to
+      // the constructor, so this has to be replaced with:
+      //   std::make_smart_ptr<S>(5);
+      //   std::make_smart_ptr<S>();
+      InitRange = SourceRange(
+          NewConstruct->getParenOrBraceRange().getBegin().getLocWithOffset(1),
+          NewConstruct->getParenOrBraceRange().getEnd().getLocWithOffset(-1));
     } else {
       // Aggregate initialization.
       //   smart_ptr<Pair>(new Pair{first, second});
Index: clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp
@@ -59,7 +59,7 @@
   SourceLocation EndLoc = IoStateLoc.getLocWithOffset(TypeName.size() - 1);
 
   if (Replacement) {
-    const auto *FixName = *Replacement;
+    const char *FixName = *Replacement;
     auto Builder = diag(IoStateLoc, "'std::ios_base::%0' is deprecated; use "
                                     "'std::ios_base::%1' instead")
                    << TypeName << FixName;
Index: clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
@@ -334,7 +334,7 @@
 
   ArrayRef<BindArgument> Args = LP.BindArguments;
 
-  const auto *MaxPlaceholderIt =
+  auto MaxPlaceholderIt =
       std::max_element(Args.begin(), Args.end(),
                        [](const BindArgument &B1, const BindArgument &B2) {
                          return B1.PlaceHolderIndex < B2.PlaceHolderIndex;
Index: clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
+++ clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
@@ -85,8 +85,7 @@
     return 2;
   if (T->isIntegralType(Context))
     return twoPow(Context.getTypeSize(T));
-  else
-    return 1;
+  return 1;
 }
 
 void MultiwayPathsCoveredCheck::check(const MatchFinder::MatchResult &Result) {
Index: clang-tools-extra/clang-tidy/bugprone/SpuriouslyWakeUpFunctionsCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/bugprone/SpuriouslyWakeUpFunctionsCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/SpuriouslyWakeUpFunctionsCheck.cpp
@@ -60,7 +60,6 @@
     // Check for `CON54-CPP`
     Finder->addMatcher(
         ifStmt(
-
             allOf(HasWaitDescendantCpp,
                   unless(anyOf(hasDescendant(ifStmt(HasWaitDescendantCpp)),
                                hasDescendant(whileStmt(HasWaitDescendantCpp)),
@@ -72,7 +71,6 @@
   } else {
     // Check for `CON36-C`
     Finder->addMatcher(
-
         ifStmt(
             allOf(HasWaitDescendantC,
                   unless(anyOf(hasDescendant(ifStmt(HasWaitDescendantC)),
Index: clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
@@ -39,7 +39,8 @@
   if (const auto *UE = dyn_cast<UnaryOperator>(E)) {
     const auto M = hasSizeOfDescendant(Depth - 1, InnerMatcher);
     return M.matches(*UE->getSubExpr(), Finder, Builder);
-  } else if (const auto *BE = dyn_cast<BinaryOperator>(E)) {
+  }
+  if (const auto *BE = dyn_cast<BinaryOperator>(E)) {
     const auto LHS = hasSizeOfDescendant(Depth - 1, InnerMatcher);
     const auto RHS = hasSizeOfDescendant(Depth - 1, InnerMatcher);
     return LHS.matches(*BE->getLHS(), Finder, Builder) ||
Index: clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
@@ -920,8 +920,7 @@
 void NotNullTerminatedResultCheck::memchrFix(
     StringRef Name, const MatchFinder::MatchResult &Result) {
   const auto *FunctionExpr = Result.Nodes.getNodeAs<CallExpr>(FunctionExprName);
-  if (const auto *const GivenCL =
-          dyn_cast<CharacterLiteral>(FunctionExpr->getArg(1)))
+  if (const auto *GivenCL = dyn_cast<CharacterLiteral>(FunctionExpr->getArg(1)))
     if (GivenCL->getValue() != 0)
       return;
 
Index: clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp
@@ -106,8 +106,7 @@
 
   // Every parameter after the first must have a default value.
   const auto *Ctor = Result.Nodes.getNodeAs<CXXConstructorDecl>("ctor");
-  for (const 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;
   }
Index: clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
@@ -188,10 +188,10 @@
         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;
Index: clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
@@ -280,7 +280,7 @@
     IdentifierInfo *II = PVD->getIdentifier();
     if (!II)
       continue;
-    if (auto *Template = Callee->getTemplateInstantiationPattern()) {
+    if (FunctionDecl *Template = Callee->getTemplateInstantiationPattern()) {
       // Don't warn on arguments for parameters instantiated from template
       // parameter packs. If we find more arguments than the template
       // definition has, it also means that they correspond to a parameter
Index: clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp
+++ clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp
@@ -93,7 +93,7 @@
 }
 
 void TimeSubtractionCheck::registerMatchers(MatchFinder *Finder) {
-  for (const auto *ScaleName :
+  for (const char *ScaleName :
        {"Hours", "Minutes", "Seconds", "Millis", "Micros", "Nanos"}) {
     std::string TimeInverse = (llvm::Twine("ToUnix") + ScaleName).str();
     llvm::Optional<DurationScale> Scale = getScaleForTimeInverse(TimeInverse);
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to