Author: Baranov Victor
Date: 2026-08-27T09:03:19+03:00
New Revision: 5bc0be4e100bafb1c3e0e9e9632fb1947af13ffb

URL: 
https://github.com/llvm/llvm-project/commit/5bc0be4e100bafb1c3e0e9e9632fb1947af13ffb
DIFF: 
https://github.com/llvm/llvm-project/commit/5bc0be4e100bafb1c3e0e9e9632fb1947af13ffb.diff

LOG: [clang-tidy][NFC] Fix couple clang-tidy violations (#219006)

Added: 
    

Modified: 
    clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
    clang-tools-extra/clang-tidy/llvm/InvalidRegexPatternCheck.cpp
    clang-tools-extra/clang-tidy/misc/StaticInitializationCycleCheck.cpp
    
clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp
    clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
index 88bd2b708d4cb..2ceee8ff79ef5 100644
--- a/clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
@@ -70,7 +70,7 @@ static bool isVarPossiblyChanged(const Decl *Func, const Stmt 
*LoopStmt,
   if (const auto *VarD = dyn_cast<VarDecl>(VD)) {
     Var = VarD;
   } else if (const auto *BD = dyn_cast<BindingDecl>(VD)) {
-    if (const auto *DD = dyn_cast<DecompositionDecl>(BD->getDecomposedDecl()))
+    if (const DecompositionDecl *DD = BD->getDecomposedDecl())
       Var = DD;
   }
 
@@ -230,7 +230,7 @@ static bool hasStaticLocalVariable(const Stmt *Cond) {
       return true;
 
     if (const auto *BD = dyn_cast<BindingDecl>(DRE->getDecl()))
-      if (const auto *DD = 
dyn_cast<DecompositionDecl>(BD->getDecomposedDecl());
+      if (const DecompositionDecl *DD = BD->getDecomposedDecl();
           DD && DD->isStaticLocal())
         return true;
   }

diff  --git a/clang-tools-extra/clang-tidy/llvm/InvalidRegexPatternCheck.cpp 
b/clang-tools-extra/clang-tidy/llvm/InvalidRegexPatternCheck.cpp
index 7ffc03f9795b8..a7390d10272b9 100644
--- a/clang-tools-extra/clang-tidy/llvm/InvalidRegexPatternCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvm/InvalidRegexPatternCheck.cpp
@@ -30,18 +30,18 @@ void InvalidRegexPatternCheck::registerMatchers(MatchFinder 
*Finder) {
       hasUnqualifiedDesugaredType(arrayType(hasElementType(builtinType()))));
   auto IsStdStringView = qualType(hasUnqualifiedDesugaredType(recordType(
       hasDeclaration(cxxRecordDecl(hasName("::std::basic_string_view"))))));
-  auto HasStringContainerType =
+  const auto HasStringContainerType =
       hasType(qualType(anyOf(IsConstStdString, IsConstllvmStringRef,
                              IsStdStringView, IsConstCharPtr, IsCharArray)));
-  auto GetString = anyOf(GetStringLiteralFromObject, GetStringLiteral);
-  auto AnyCastedToStringRef = ignoringImplicit(
+  const auto GetString = anyOf(GetStringLiteralFromObject, GetStringLiteral);
+  const auto AnyCastedToStringRef = ignoringImplicit(
       anyOf(stringLiteral().bind("stringLiteral"),
             declRefExpr(
                 to(varDecl(HasStringContainerType, 
hasInitializer(GetString)))),
             memberExpr(member(fieldDecl(HasStringContainerType,
                                         hasInClassInitializer(GetString))))));
 
-  auto IsRegexFlagsType = ignoringParenImpCasts(
+  const auto IsRegexFlagsType = ignoringParenImpCasts(
       anyOf(integerLiteral().bind("regexFlagsInt"),
             declRefExpr(to(enumConstantDecl().bind("regexFlagEnum")))));
   Finder->addMatcher(

diff  --git 
a/clang-tools-extra/clang-tidy/misc/StaticInitializationCycleCheck.cpp 
b/clang-tools-extra/clang-tidy/misc/StaticInitializationCycleCheck.cpp
index 790b76b784ea4..a1fde21ac0621 100644
--- a/clang-tools-extra/clang-tidy/misc/StaticInitializationCycleCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/StaticInitializationCycleCheck.cpp
@@ -199,21 +199,19 @@ class VarUseCollector : public DynamicRecursiveASTVisitor 
{
   }
 
   bool VisitDeclRefExpr(DeclRefExpr *DRE) override {
-    if (const auto *VarD = dyn_cast<VarDecl>(DRE->getDecl())) {
-      if (!shouldIgnoreRef(DRE, Node->getDecl()) &&
-          (VarD->hasGlobalStorage() || VarD->isStaticLocal()))
-        Node->Uses.emplace_back(DRE, G.addNode(VarD->getCanonicalDecl()));
-    }
+    if (const auto *VarD = dyn_cast<VarDecl>(DRE->getDecl());
+        VarD && (!shouldIgnoreRef(DRE, Node->getDecl()) &&
+                 (VarD->hasGlobalStorage() || VarD->isStaticLocal())))
+      Node->Uses.emplace_back(DRE, G.addNode(VarD->getCanonicalDecl()));
     return true;
   }
 
   bool VisitCallExpr(CallExpr *CE) override {
-    if (const FunctionDecl *F = CE->getDirectCallee()) {
-      if (F->isGlobal() || F->isStatic()) {
-        const FunctionDecl *Def = F->getDefinition();
-        if (Def)
-          Node->Uses.emplace_back(CE, G.addNode(Def));
-      }
+    if (const FunctionDecl *F = CE->getDirectCallee();
+        F && (F->isGlobal() || F->isStatic())) {
+      const FunctionDecl *Def = F->getDefinition();
+      if (Def)
+        Node->Uses.emplace_back(CE, G.addNode(Def));
     }
     return true;
   }

diff  --git 
a/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp
index 59821aed311b3..d7f1b73438177 100644
--- 
a/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp
@@ -26,7 +26,6 @@
 #include <cassert>
 #include <optional>
 #include <stack>
-#include <tuple>
 #include <utility>
 
 using namespace clang::ast_matchers;

diff  --git 
a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
index 4ac23948c5e01..50644bbf37bce 100644
--- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -12,7 +12,7 @@
 #include "../utils/ASTUtils.h"
 #include "clang/AST/CXXInheritance.h"
 #include "clang/Lex/PPCallbacks.h"
-#include "clang/Lex/Preprocessor.h"
+#include "clang/Lex/Token.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Debug.h"
@@ -1244,7 +1244,7 @@ StyleKind IdentifierNamingCheck::findStyleKind(
   // C++17 structured bindings: treat each binding as if it were a variable
   // with the same storage and qualifiers as the parent DecompositionDecl.
   if (const auto *BD = dyn_cast<BindingDecl>(D)) {
-    if (const auto *Decomp = 
dyn_cast_or_null<VarDecl>(BD->getDecomposedDecl());
+    if (const DecompositionDecl *Decomp = BD->getDecomposedDecl();
         Decomp && !BD->getType().isNull())
       return findStyleKindForVar(Decomp, BD->getType(), NamingStyles);
     return SK_Invalid;


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to