Skip to content

Conversation

@vbvictor
Copy link
Contributor

@vbvictor vbvictor commented Nov 7, 2025

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Nov 7, 2025

@llvm/pr-subscribers-clang-tidy

@llvm/pr-subscribers-clang-tools-extra

Author: Baranov Victor (vbvictor)

Changes

Patch is 38.63 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/167040.diff

31 Files Affected:

  • (modified) clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h (+2-2)
  • (modified) clang-tools-extra/clang-tidy/abseil/DurationAdditionCheck.cpp (+1-1)
  • (modified) clang-tools-extra/clang-tidy/abseil/DurationComparisonCheck.cpp (+2-2)
  • (modified) clang-tools-extra/clang-tidy/abseil/DurationConversionCastCheck.cpp (+5-3)
  • (modified) clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp (+1-1)
  • (modified) clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp (+2-2)
  • (modified) clang-tools-extra/clang-tidy/abseil/DurationSubtractionCheck.cpp (+1-1)
  • (modified) clang-tools-extra/clang-tidy/abseil/DurationUnnecessaryConversionCheck.cpp (+3-3)
  • (modified) clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp (+1-1)
  • (modified) clang-tools-extra/clang-tidy/abseil/NoInternalDependenciesCheck.cpp (+1-1)
  • (modified) clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp (+2-2)
  • (modified) clang-tools-extra/clang-tidy/abseil/TimeComparisonCheck.cpp (+2-2)
  • (modified) clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp (+4-4)
  • (modified) clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp (+5-5)
  • (modified) clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.cpp (+7-7)
  • (modified) clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.h (+2-2)
  • (modified) clang-tools-extra/clang-tidy/altera/KernelNameRestrictionCheck.cpp (+2-2)
  • (modified) clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp (+15-13)
  • (modified) clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp (+1-1)
  • (modified) clang-tools-extra/clang-tidy/android/CloexecAcceptCheck.cpp (+5-4)
  • (modified) clang-tools-extra/clang-tidy/android/CloexecCheck.cpp (+5-4)
  • (modified) clang-tools-extra/clang-tidy/android/CloexecDupCheck.cpp (+1-1)
  • (modified) clang-tools-extra/clang-tidy/android/CloexecOpenCheck.cpp (+1-1)
  • (modified) clang-tools-extra/clang-tidy/android/CloexecPipeCheck.cpp (+1-1)
  • (modified) clang-tools-extra/clang-tidy/android/ComparisonInTempFailureRetryCheck.cpp (+1-1)
  • (modified) clang-tools-extra/clang-tidy/boost/UseRangesCheck.cpp (+1-1)
  • (modified) clang-tools-extra/clang-tidy/objc/AssertEquals.cpp (+2-2)
  • (modified) clang-tools-extra/clang-tidy/objc/NSDateFormatterCheck.cpp (+1-1)
  • (modified) clang-tools-extra/clang-tidy/objc/NSInvocationArgumentLifetimeCheck.cpp (+6-6)
  • (modified) clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp (+6-5)
  • (modified) clang-tools-extra/clang-tidy/objc/SuperSelfCheck.cpp (+2-2)
diff --git a/clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h b/clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h
index ac2e759c4c270..982774ca4db5b 100644
--- a/clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h
+++ b/clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h
@@ -34,7 +34,7 @@ AST_POLYMORPHIC_MATCHER(
     isInAbseilFile, AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Stmt, TypeLoc,
                                                     NestedNameSpecifierLoc)) {
   auto &SourceManager = Finder->getASTContext().getSourceManager();
-  SourceLocation Loc = SourceManager.getSpellingLoc(Node.getBeginLoc());
+  const SourceLocation Loc = SourceManager.getSpellingLoc(Node.getBeginLoc());
   if (Loc.isInvalid())
     return false;
   OptionalFileEntryRef FileEntry =
@@ -45,7 +45,7 @@ AST_POLYMORPHIC_MATCHER(
   // [absl-library] is AbseilLibraries list entry.
   StringRef Path = FileEntry->getName();
   static constexpr llvm::StringLiteral AbslPrefix("absl/");
-  size_t PrefixPosition = Path.find(AbslPrefix);
+  const size_t PrefixPosition = Path.find(AbslPrefix);
   if (PrefixPosition == StringRef::npos)
     return false;
   Path = Path.drop_front(PrefixPosition + AbslPrefix.size());
diff --git a/clang-tools-extra/clang-tidy/abseil/DurationAdditionCheck.cpp b/clang-tools-extra/clang-tidy/abseil/DurationAdditionCheck.cpp
index 03f78f1c96252..421e5973d4fe0 100644
--- a/clang-tools-extra/clang-tidy/abseil/DurationAdditionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/DurationAdditionCheck.cpp
@@ -41,7 +41,7 @@ void DurationAdditionCheck::check(const MatchFinder::MatchResult &Result) {
   if (!Scale)
     return;
 
-  llvm::StringRef TimeFactory = getTimeInverseForScale(*Scale);
+  const llvm::StringRef TimeFactory = getTimeInverseForScale(*Scale);
 
   FixItHint Hint;
   if (Call == Binop->getLHS()->IgnoreParenImpCasts()) {
diff --git a/clang-tools-extra/clang-tidy/abseil/DurationComparisonCheck.cpp b/clang-tools-extra/clang-tidy/abseil/DurationComparisonCheck.cpp
index 16a244b7e9997..f00877754f952 100644
--- a/clang-tools-extra/clang-tidy/abseil/DurationComparisonCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/DurationComparisonCheck.cpp
@@ -38,9 +38,9 @@ void DurationComparisonCheck::check(const MatchFinder::MatchResult &Result) {
   // if nothing needs to be done.
   if (isInMacro(Result, Binop->getLHS()) || isInMacro(Result, Binop->getRHS()))
     return;
-  std::string LhsReplacement =
+  const std::string LhsReplacement =
       rewriteExprFromNumberToDuration(Result, *Scale, Binop->getLHS());
-  std::string RhsReplacement =
+  const std::string RhsReplacement =
       rewriteExprFromNumberToDuration(Result, *Scale, Binop->getRHS());
 
   diag(Binop->getBeginLoc(), "perform comparison in the duration domain")
diff --git a/clang-tools-extra/clang-tidy/abseil/DurationConversionCastCheck.cpp b/clang-tools-extra/clang-tidy/abseil/DurationConversionCastCheck.cpp
index 11d6017c22e9d..ef06a9e2ba572 100644
--- a/clang-tools-extra/clang-tidy/abseil/DurationConversionCastCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/DurationConversionCastCheck.cpp
@@ -41,7 +41,7 @@ void DurationConversionCastCheck::check(
 
   const auto *FuncDecl = Result.Nodes.getNodeAs<FunctionDecl>("func_decl");
   const auto *Arg = Result.Nodes.getNodeAs<Expr>("arg");
-  StringRef ConversionFuncName = FuncDecl->getName();
+  const StringRef ConversionFuncName = FuncDecl->getName();
 
   std::optional<DurationScale> Scale =
       getScaleForDurationInverse(ConversionFuncName);
@@ -51,7 +51,8 @@ void DurationConversionCastCheck::check(
   // Casting a double to an integer.
   if (MatchedCast->getTypeAsWritten()->isIntegerType() &&
       ConversionFuncName.contains("Double")) {
-    llvm::StringRef NewFuncName = getDurationInverseForScale(*Scale).second;
+    const llvm::StringRef NewFuncName =
+        getDurationInverseForScale(*Scale).second;
 
     diag(MatchedCast->getBeginLoc(),
          "duration should be converted directly to an integer rather than "
@@ -66,7 +67,8 @@ void DurationConversionCastCheck::check(
   // Casting an integer to a double.
   if (MatchedCast->getTypeAsWritten()->isRealFloatingType() &&
       ConversionFuncName.contains("Int64")) {
-    llvm::StringRef NewFuncName = getDurationInverseForScale(*Scale).first;
+    const llvm::StringRef NewFuncName =
+        getDurationInverseForScale(*Scale).first;
 
     diag(MatchedCast->getBeginLoc(), "duration should be converted directly to "
                                      "a floating-point number rather than "
diff --git a/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp b/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
index 334629767aff2..9e403fb8be3dd 100644
--- a/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
@@ -158,7 +158,7 @@ void DurationFactoryScaleCheck::check(const MatchFinder::MatchResult &Result) {
   if (!MaybeScale)
     return;
 
-  DurationScale Scale = *MaybeScale;
+  const DurationScale Scale = *MaybeScale;
   const Expr *Remainder = nullptr;
   std::optional<DurationScale> NewScale;
 
diff --git a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
index ee1979658aaed..a78d07d2e5861 100644
--- a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
@@ -20,7 +20,7 @@ namespace clang::tidy::abseil {
 /// Returns an integer if the fractional part of a `FloatingLiteral` is `0`.
 static std::optional<llvm::APSInt>
 truncateIfIntegral(const FloatingLiteral &FloatLiteral) {
-  double Value = FloatLiteral.getValueAsApproximateDouble();
+  const double Value = FloatLiteral.getValueAsApproximateDouble();
   if (std::fmod(Value, 1) == 0) {
     if (Value >= static_cast<double>(1U << 31))
       return std::nullopt;
@@ -69,7 +69,7 @@ rewriteInverseDurationCall(const MatchFinder::MatchResult &Result,
 static std::optional<std::string>
 rewriteInverseTimeCall(const MatchFinder::MatchResult &Result,
                        DurationScale Scale, const Expr &Node) {
-  llvm::StringRef InverseFunction = getTimeInverseForScale(Scale);
+  const llvm::StringRef InverseFunction = getTimeInverseForScale(Scale);
   if (const auto *MaybeCallArg = selectFirst<const Expr>(
           "e", match(callExpr(callee(functionDecl(hasName(InverseFunction))),
                               hasArgument(0, expr().bind("e"))),
diff --git a/clang-tools-extra/clang-tidy/abseil/DurationSubtractionCheck.cpp b/clang-tools-extra/clang-tidy/abseil/DurationSubtractionCheck.cpp
index c5d93ad51ad17..42a7df496f6ad 100644
--- a/clang-tools-extra/clang-tidy/abseil/DurationSubtractionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/DurationSubtractionCheck.cpp
@@ -41,7 +41,7 @@ void DurationSubtractionCheck::check(const MatchFinder::MatchResult &Result) {
   if (!Scale)
     return;
 
-  std::string RhsReplacement =
+  const std::string RhsReplacement =
       rewriteExprFromNumberToDuration(Result, *Scale, Binop->getRHS());
 
   const Expr *LhsArg = Result.Nodes.getNodeAs<Expr>("lhs_arg");
diff --git a/clang-tools-extra/clang-tidy/abseil/DurationUnnecessaryConversionCheck.cpp b/clang-tools-extra/clang-tidy/abseil/DurationUnnecessaryConversionCheck.cpp
index 805d7dacd4eec..5867fb630315d 100644
--- a/clang-tools-extra/clang-tidy/abseil/DurationUnnecessaryConversionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/DurationUnnecessaryConversionCheck.cpp
@@ -19,10 +19,10 @@ namespace clang::tidy::abseil {
 void DurationUnnecessaryConversionCheck::registerMatchers(MatchFinder *Finder) {
   for (const auto &Scale : {"Hours", "Minutes", "Seconds", "Milliseconds",
                             "Microseconds", "Nanoseconds"}) {
-    std::string DurationFactory = (llvm::Twine("::absl::") + Scale).str();
-    std::string FloatConversion =
+    const std::string DurationFactory = (llvm::Twine("::absl::") + Scale).str();
+    const std::string FloatConversion =
         (llvm::Twine("::absl::ToDouble") + Scale).str();
-    std::string IntegerConversion =
+    const std::string IntegerConversion =
         (llvm::Twine("::absl::ToInt64") + Scale).str();
 
     // Matcher which matches the current scale's factory with a `1` argument,
diff --git a/clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp b/clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp
index d9f6551739d9e..0827526ba3b5d 100644
--- a/clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp
@@ -29,7 +29,7 @@ makeCharacterLiteral(const StringLiteral *Literal, const ASTContext &Context) {
   assert(Literal->getCharByteWidth() == 1 &&
          "StrSplit doesn't support wide char");
   std::string Result = clang::tooling::fixit::getText(*Literal, Context).str();
-  bool IsRawStringLiteral = StringRef(Result).starts_with(R"(R")");
+  const bool IsRawStringLiteral = StringRef(Result).starts_with(R"(R")");
   // Since raw string literal might contain unescaped non-printable characters,
   // we normalize them using `StringLiteral::outputString`.
   if (IsRawStringLiteral) {
diff --git a/clang-tools-extra/clang-tidy/abseil/NoInternalDependenciesCheck.cpp b/clang-tools-extra/clang-tidy/abseil/NoInternalDependenciesCheck.cpp
index c090e5ac54222..5f4cb66424700 100644
--- a/clang-tools-extra/clang-tidy/abseil/NoInternalDependenciesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/NoInternalDependenciesCheck.cpp
@@ -32,7 +32,7 @@ void NoInternalDependenciesCheck::check(
   const auto *InternalDependency =
       Result.Nodes.getNodeAs<NestedNameSpecifierLoc>("InternalDep");
 
-  SourceLocation LocAtFault =
+  const SourceLocation LocAtFault =
       Result.SourceManager->getSpellingLoc(InternalDependency->getBeginLoc());
 
   if (!LocAtFault.isValid())
diff --git a/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp b/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
index 92d63057caf65..e1063c4f8a46e 100644
--- a/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
@@ -92,7 +92,7 @@ void StringFindStartswithCheck::check(const MatchFinder::MatchResult &Result) {
   const auto *FindFun = Result.Nodes.getNodeAs<CXXMethodDecl>("findfun");
   assert(FindFun != nullptr);
 
-  bool Rev = FindFun->getName().contains("rfind");
+  const bool Rev = FindFun->getName().contains("rfind");
 
   if (ComparisonExpr->getBeginLoc().isMacroID())
     return;
@@ -107,7 +107,7 @@ void StringFindStartswithCheck::check(const MatchFinder::MatchResult &Result) {
       Context.getLangOpts());
 
   // Create the StartsWith string, negating if comparison was "!=".
-  bool Neg = ComparisonExpr->getOpcode() == BO_NE;
+  const bool Neg = ComparisonExpr->getOpcode() == BO_NE;
 
   // Create the warning message and a FixIt hint replacing the original expr.
   auto Diagnostic =
diff --git a/clang-tools-extra/clang-tidy/abseil/TimeComparisonCheck.cpp b/clang-tools-extra/clang-tidy/abseil/TimeComparisonCheck.cpp
index 7a97a1895ad02..5d80b16239838 100644
--- a/clang-tools-extra/clang-tidy/abseil/TimeComparisonCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/TimeComparisonCheck.cpp
@@ -39,9 +39,9 @@ void TimeComparisonCheck::check(const MatchFinder::MatchResult &Result) {
   // want to handle the case of rewriting both sides. This is much simpler if
   // we unconditionally try and rewrite both, and let the rewriter determine
   // if nothing needs to be done.
-  std::string LhsReplacement =
+  const std::string LhsReplacement =
       rewriteExprFromNumberToTime(Result, *Scale, Binop->getLHS());
-  std::string RhsReplacement =
+  const std::string RhsReplacement =
       rewriteExprFromNumberToTime(Result, *Scale, Binop->getRHS());
 
   diag(Binop->getBeginLoc(), "perform comparison in the time domain")
diff --git a/clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp b/clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp
index 228d974cd5e23..4ae49d285930d 100644
--- a/clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp
@@ -93,7 +93,7 @@ void TimeSubtractionCheck::emitDiagnostic(const Expr *Node,
 void TimeSubtractionCheck::registerMatchers(MatchFinder *Finder) {
   for (const char *ScaleName :
        {"Hours", "Minutes", "Seconds", "Millis", "Micros", "Nanos"}) {
-    std::string TimeInverse = (llvm::Twine("ToUnix") + ScaleName).str();
+    const std::string TimeInverse = (llvm::Twine("ToUnix") + ScaleName).str();
     std::optional<DurationScale> Scale = getScaleForTimeInverse(TimeInverse);
     assert(Scale && "Unknown scale encountered");
 
@@ -127,7 +127,7 @@ void TimeSubtractionCheck::registerMatchers(MatchFinder *Finder) {
 
 void TimeSubtractionCheck::check(const MatchFinder::MatchResult &Result) {
   const auto *BinOp = Result.Nodes.getNodeAs<BinaryOperator>("binop");
-  std::string InverseName =
+  const std::string InverseName =
       Result.Nodes.getNodeAs<FunctionDecl>("func_decl")->getNameAsString();
   if (insideMacroDefinition(Result, BinOp->getSourceRange()))
     return;
@@ -144,7 +144,7 @@ void TimeSubtractionCheck::check(const MatchFinder::MatchResult &Result) {
     // We're working with the first case of matcher, and need to replace the
     // entire 'Duration' factory call. (Which also means being careful about
     // our order-of-operations and optionally putting in some parenthesis.
-    bool NeedParens = parensRequired(Result, OuterCall);
+    const bool NeedParens = parensRequired(Result, OuterCall);
 
     emitDiagnostic(
         OuterCall,
@@ -169,7 +169,7 @@ void TimeSubtractionCheck::check(const MatchFinder::MatchResult &Result) {
       // converts it from the inverse to a Duration.  In this case, we replace
       // the outer with just the subtraction expression, which gives the right
       // type and scale, taking care again about parenthesis.
-      bool NeedParens = parensRequired(Result, MaybeCallArg);
+      const bool NeedParens = parensRequired(Result, MaybeCallArg);
 
       emitDiagnostic(
           MaybeCallArg,
diff --git a/clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp b/clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp
index 8b197e5b939e7..1a6ff30fc8d96 100644
--- a/clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp
@@ -117,10 +117,10 @@ void UpgradeDurationConversionsCheck::check(
       "implicit conversion to 'int64_t' is deprecated in this context; use an "
       "explicit cast instead";
 
-  TraversalKindScope RAII(*Result.Context, TK_AsIs);
+  const TraversalKindScope RAII(*Result.Context, TK_AsIs);
 
   const auto *ArgExpr = Result.Nodes.getNodeAs<Expr>("arg");
-  SourceLocation Loc = ArgExpr->getBeginLoc();
+  const SourceLocation Loc = ArgExpr->getBeginLoc();
 
   const auto *OuterExpr = Result.Nodes.getNodeAs<Expr>("OuterExpr");
 
@@ -139,13 +139,13 @@ void UpgradeDurationConversionsCheck::check(
 
   // We gather source locations from template matches not in template
   // instantiations for future matches.
-  internal::Matcher<Stmt> IsInsideTemplate =
+  const internal::Matcher<Stmt> IsInsideTemplate =
       hasAncestor(decl(anyOf(classTemplateDecl(), functionTemplateDecl())));
   if (!match(IsInsideTemplate, *ArgExpr, *Result.Context).empty())
     MatchedTemplateLocations.insert(Loc);
 
-  DiagnosticBuilder Diag = diag(Loc, Message);
-  CharSourceRange SourceRange = Lexer::makeFileCharRange(
+  const DiagnosticBuilder Diag = diag(Loc, Message);
+  const CharSourceRange SourceRange = Lexer::makeFileCharRange(
       CharSourceRange::getTokenRange(ArgExpr->getSourceRange()),
       *Result.SourceManager, Result.Context->getLangOpts());
   if (SourceRange.isInvalid())
diff --git a/clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.cpp b/clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.cpp
index 49ba17ce643fe..519d90914580f 100644
--- a/clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.cpp
+++ b/clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.cpp
@@ -76,7 +76,7 @@ void IdDependentBackwardBranchCheck::registerMatchers(MatchFinder *Finder) {
                      this);
 }
 
-IdDependentBackwardBranchCheck::IdDependencyRecord *
+const IdDependentBackwardBranchCheck::IdDependencyRecord *
 IdDependentBackwardBranchCheck::hasIdDepVar(const Expr *Expression) {
   if (!Expression)
     return nullptr;
@@ -94,12 +94,12 @@ IdDependentBackwardBranchCheck::hasIdDepVar(const Expr *Expression) {
   }
   for (const auto *Child : Expression->children())
     if (const auto *ChildExpression = dyn_cast_if_present<Expr>(Child))
-      if (IdDependencyRecord *Result = hasIdDepVar(ChildExpression))
+      if (const IdDependencyRecord *Result = hasIdDepVar(ChildExpression))
         return Result;
   return nullptr;
 }
 
-IdDependentBackwardBranchCheck::IdDependencyRecord *
+const IdDependentBackwardBranchCheck::IdDependencyRecord *
 IdDependentBackwardBranchCheck::hasIdDepField(const Expr *Expression) {
   if (!Expression)
     return nullptr;
@@ -116,7 +116,7 @@ IdDependentBackwardBranchCheck::hasIdDepField(const Expr *Expression) {
   }
   for (const auto *Child : Expression->children())
     if (const auto *ChildExpression = dyn_cast_if_present<Expr>(Child))
-      if (IdDependencyRecord *Result = hasIdDepField(ChildExpression))
+      if (const IdDependencyRecord *Result = hasIdDepField(ChildExpression))
         return Result;
   return nullptr;
 }
@@ -239,7 +239,7 @@ void IdDependentBackwardBranchCheck::check(
   const auto *Loop = Result.Nodes.getNodeAs<Stmt>("backward_branch");
   if (!Loop)
     return;
-  LoopType Type = getLoopType(Loop);
+  const LoopType Type = getLoopType(Loop);
   if (CondExpr) {
     if (IDCall) { // Conditional expression calls an ID function directly.
       diag(CondExpr->getBeginLoc(),
@@ -249,8 +249,8 @@ void IdDependentBackwardBranchCheck::check(
       return;
     }
     // Conditional expression has DeclRefExpr(s), check ID-dependency.
-    IdDependencyRecord *IdDepVar = hasIdDepVar(CondExpr);
-    IdDependencyRecord *IdDepField = hasIdDepField(CondExpr);
+    const IdDependencyRecord *IdDepVar = hasIdDepVar(CondExpr);
+    const IdDependencyRecord *IdDepField = hasIdDepField(CondExpr);
     if (IdDepVar) {
       diag(CondExpr->getBeginLoc(),
            "backward branch (%select{do|while|for}0 loop) is ID-dependent due "
diff --git a/clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.h b/clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.h
index b777918ab7e7b..297e7751e4f49 100644
--- a/clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.h
+++ b/clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.h
@@ -44,10 +44,10 @@ class IdDependentBackwardBranchCheck : public ClangTidyCheck {
   std::map<const FieldDecl *, IdDependencyRecord> IdDepFieldsMap;
   /// Returns an IdDependencyRecord if the Expression contains an ID-dependent
   /// variable, returns a nullptr otherwise.
-  IdDependencyRecord *hasIdDepVar(const Expr *Expression);
+  const IdDependencyRecord *hasIdDepVar(const Expr *Expression);
   /// Returns an IdDependencyRecord if the Expression contains an ID-dependent
   /// field, returns a nullptr otherwise.
-  IdDependencyRecord *hasIdDepField(const Expr *Expression);
+  const IdDependencyRecord *hasIdDepField(const Expr *Expression);
   /// Stores the location an ID-dependent variable is created from a call to
   /// an ID function in IdDepVarsMap.
   void saveIdDepVar(const Stmt *Statement, const VarDecl *Variable);
diff --git a/clang-tools-extra/clang-tidy/altera/KernelNameRestrictionCheck.cpp b/clang-tools-extra/clang-tidy/altera/KernelNameRestrictionCheck.cpp
index 4c740e31ae7be..8aa23b8fc7b11 100644
--- a/clang-tools-extra/clang-tidy/altera/KernelNameRestrictionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/altera/KernelNameRestrictionCheck.cpp
@@ -77,7 +77,7 @@ void KernelNameRestrictionPPCallbacks::EndOfMainFile() {
 
   // Check main file for restricted names.
   OptionalFileEntryRef Entry = SM.getFileE...
[truncated]

// Mapping from `XCTAssert*Equal` to `XCTAssert*EqualObjects` name.
static const std::map<std::string, std::string> &nameMap() {
static std::map<std::string, std::string> Map{
static const std::map<std::string, std::string> Map{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For another pull request: may be LLVM has better data structure?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we could use DenseMap.

@vbvictor vbvictor enabled auto-merge (squash) November 7, 2025 23:07
@vbvictor vbvictor merged commit bbc4a45 into llvm:main Nov 7, 2025
12 of 13 checks passed
Copy link
Contributor

@localspook localspook left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

vinay-deshmukh pushed a commit to vinay-deshmukh/llvm-project that referenced this pull request Nov 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants