Skip to content

Commit dca6c74

Browse files
author
Carlos Gálvez
committed
[clang-tidy] Skip declarations in system headers in RenamerClangTidyCheck
One typically only wants to perform renaming operations in user code, not in system headers (which are out of the user's control). Let's skip those altogether. This leads to performance improvements in clang-tidy. As a benchmark, I run all checks on a .cpp file that #includes all C++ standard headers. On trunk: Suppressed 213362 warnings (213362 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. real 0m14.517s user 0m14.383s sys 0m0.132s On this patch: Suppressed 75107 warnings (75107 in non-user code). real 0m12.545s user 0m12.349s sys 0m0.188s
1 parent c696ecd commit dca6c74

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,9 @@ RenamerClangTidyCheck::addUsage(
455455
void RenamerClangTidyCheck::addUsage(const NamedDecl *Decl,
456456
SourceRange UsageRange,
457457
const SourceManager &SourceMgr) {
458+
if (SourceMgr.isInSystemHeader(Decl->getLocation()))
459+
return;
460+
458461
if (hasNoName(Decl))
459462
return;
460463

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ Changes in existing checks
130130
<clang-tidy/checks/bugprone/infinite-loop>` check by adding detection for
131131
variables introduced by structured bindings.
132132

133+
- Improved :doc:`bugprone-reserved-identifier
134+
<clang-tidy/checks/bugprone/reserved-identifier>` check by ignoring
135+
declarations in system headers.
136+
133137
- Improved :doc:`bugprone-signed-char-misuse
134138
<clang-tidy/checks/bugprone/signed-char-misuse>` check by fixing
135139
false positives on C23 enums with the fixed underlying type of signed char.
@@ -160,6 +164,10 @@ Changes in existing checks
160164
<clang-tidy/checks/portability/template-virtual-member-function>` check to
161165
avoid false positives on pure virtual member functions.
162166

167+
- Improved :doc:`readability-identifier-naming
168+
<clang-tidy/checks/readability/identifier-naming>` check by ignoring
169+
declarations in system headers.
170+
163171
- Improved :doc:`readability-qualified-auto
164172
<clang-tidy/checks/readability/qualified-auto>` check by adding the option
165173
`IgnoreAliasing`, that allows not looking at underlying types of type aliases.

0 commit comments

Comments
 (0)