| commit | c56c349d39464d859b0f8655a4502e5c06924b66 | [log] [tgz] |
|---|---|---|
| author | Richard Smith <richard@metafoo.co.uk> | Tue Jul 01 13:31:46 2025 -0700 |
| committer | GitHub <noreply@github.com> | Tue Jul 01 13:31:46 2025 -0700 |
| tree | 1a1857ac780b992800ba2d7a10cf087305521003 | |
| parent | a06117142632baaf489d9c7c494e27056142a25e [diff] |
[clang-tidy] Switch misc-confusable-identifiers check to a faster algorithm. (#130369) Optimizations: - Only build the skeleton for each identifier once, rather than once for each declaration of that identifier. - Only compute the contexts in which identifiers are declared for identifiers that have the same skeleton as another identifier in the translation unit. - Only compare pairs of declarations that are declared in related contexts, rather than comparing all pairs of declarations with the same skeleton. Also simplify by removing the caching of enclosing `DeclContext` sets, because with the above changes we don't even compute the enclosing `DeclContext` sets in common cases. Instead, we terminate the traversal to enclosing `DeclContext`s immediately if we've already found another declaration in that context with the same identifier. (This optimization is not currently applied to the `forallBases` traversal, but could be applied there too if needed.) This also fixes two bugs that together caused the check to fail to find some of the issues it was looking for: - The old check skipped comparisons of declarations from different contexts unless both declarations were type template parameters. This caused the checker to not warn on some instances of the CVE it is intended to detect. - The old check skipped comparisons of declarations in all base classes other than the first one found by the traversal. This appears to be an oversight, incorrectly returning `false` rather than `true` from the `forallBases` callback, which terminates traversal. This also fixes an issue where the check would have false positives for template parameters and function parameters in some cases, because those parameters sometimes have a parent `DeclContext` that is the parent of the parameterized entity, or sometimes is the translation unit. In either case, this would cause warnings about declarations that are never visible together in any scope. This decreases the runtime of this check, especially in the common case where there are few or no skeletons with two or more different identifiers. Running this check over LLVM, clang, and clang-tidy, the wall time for the check as reported by clang-tidy's internal profiler is reduced from 5202.86s to 3900.90s.
Welcome to the LLVM project!
This repository contains the source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and run-time environments.
The LLVM project has multiple components. The core of the project is itself called “LLVM”. This contains all of the tools, libraries, and header files needed to process intermediate representations and convert them into object files. Tools include an assembler, disassembler, bitcode analyzer, and bitcode optimizer.
C-like languages use the Clang frontend. This component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode -- and from there into object files, using LLVM.
Other components include: the libc++ C++ standard library, the LLD linker, and more.
Consult the Getting Started with LLVM page for information on building and running LLVM.
For information on how to contribute to the LLVM project, please take a look at the Contributing to LLVM guide.
Join the LLVM Discourse forums, Discord chat, LLVM Office Hours or Regular sync-ups.
The LLVM project has adopted a code of conduct for participants to all modes of communication within the project.