Skip to content

Conversation

@vbvictor
Copy link
Contributor

@vbvictor vbvictor commented Nov 8, 2025

After successful misc-const-correctness cleanup (last patch #167131), we can enable misc-const-correctness rule for the whole project.

During cleanup, I didn't encounter any false positives so it's safe to assume that we will have minimal FP in the future.

@llvmbot
Copy link
Member

llvmbot commented Nov 8, 2025

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

@llvm/pr-subscribers-clang-tidy

Author: Baranov Victor (vbvictor)

Changes

After successful misc-const-correctness cleanup (last patch #167131), we can enable misc-const-correctness rule for the whole project.

During cleanup, I didn't encounter any false positives so it's safe to assume that we will have minimal FP in the future.


Full diff: https://github.com/llvm/llvm-project/pull/167172.diff

2 Files Affected:

  • (modified) clang-tools-extra/clang-tidy/.clang-tidy (+1)
  • (modified) clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp (+4-3)
diff --git a/clang-tools-extra/clang-tidy/.clang-tidy b/clang-tools-extra/clang-tidy/.clang-tidy
index 0c2f34b529016..24f7d9ffdcf50 100644
--- a/clang-tools-extra/clang-tidy/.clang-tidy
+++ b/clang-tools-extra/clang-tidy/.clang-tidy
@@ -7,6 +7,7 @@ Checks: >
   -bugprone-narrowing-conversions,
   -bugprone-unchecked-optional-access,
   -bugprone-unused-return-value,
+  misc-const-correctness,
   modernize-*,
   -modernize-avoid-c-arrays,
   -modernize-pass-by-value,
diff --git a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
index 8ead26407ee5d..ac0adc498e2cc 100644
--- a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
+++ b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
@@ -601,13 +601,14 @@ ExceptionAnalyzer::throwsException(const Stmt *St,
     // whether the call itself throws.
     if (const auto *Call = dyn_cast<CallExpr>(St)) {
       if (const FunctionDecl *Func = Call->getDirectCallee()) {
-        ExceptionInfo Excs =
+        const ExceptionInfo Excs =
             throwsException(Func, Caught, CallStack, Call->getBeginLoc());
         Results.merge(Excs);
       }
     } else if (const auto *Construct = dyn_cast<CXXConstructExpr>(St)) {
-      ExceptionInfo Excs = throwsException(Construct->getConstructor(), Caught,
-                                           CallStack, Construct->getBeginLoc());
+      const ExceptionInfo Excs =
+          throwsException(Construct->getConstructor(), Caught, CallStack,
+                          Construct->getBeginLoc());
       Results.merge(Excs);
     }
   }

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