Skip to content

Commit 6eb372e

Browse files
authored
[clang-tidy] Improve performance of misc-const-correctness (#72705)
Replaced certain AST matchers in ExprMutationAnalyzer with a more direct utilization of AST classes. The primary bottleneck was identified in the canResolveToExpr AST matcher. Since this matcher was employed multiple times and used recursively, each invocation led to the constant creation and destruction of other matchers within it. Additionally, the continual comparison of DynTypedNode resulted in significant performance degradation. The optimization was tested on the TargetLowering.cpp file. Originally, the check took 156 seconds on that file, but after implementing this enhancement, it now takes approximately 40 seconds, making it nearly four times faster. Despite this improvement, there are still numerous issues in this file. To further reduce the computational cost of this class, it is advisable to consider removing the remaining matchers and exploring alternatives such as leveraging RecursiveASTVisitor and increasing the direct use of AST classes. Closes #71786
1 parent c9da4dc commit 6eb372e

File tree

2 files changed

+193
-165
lines changed

2 files changed

+193
-165
lines changed

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,8 @@ Changes in existing checks
368368
<clang-tidy/checks/misc/const-correctness>` check to avoid false positive when
369369
using pointer to member function. Additionally, the check no longer emits
370370
a diagnostic when a variable that is not type-dependent is an operand of a
371-
type-dependent binary operator.
371+
type-dependent binary operator. Improved performance of the check through
372+
optimizations.
372373

373374
- Improved :doc:`misc-include-cleaner
374375
<clang-tidy/checks/misc/include-cleaner>` check by adding option

0 commit comments

Comments
 (0)