Skip to content

Commit 6504546

Browse files
maflckoMarcoFalke
andauthored
[clang-tidy][use-internal-linkage] fix false positive for consteval function (#122141)
Fixes #122096 --------- Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^[email protected]>
1 parent 05dfbc1 commit 6504546

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

clang-tools-extra/clang-tidy/misc/UseInternalLinkageCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ void UseInternalLinkageCheck::registerMatchers(MatchFinder *Finder) {
125125
exportDecl()))))));
126126
Finder->addMatcher(
127127
functionDecl(Common, hasBody(),
128-
unless(anyOf(cxxMethodDecl(),
128+
unless(anyOf(cxxMethodDecl(), isConsteval(),
129129
isAllocationOrDeallocationOverloadedFunction(),
130130
isMain())))
131131
.bind("fn"),

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,9 @@ Changes in existing checks
286286

287287
- Improved :doc:`misc-use-internal-linkage
288288
<clang-tidy/checks/misc/use-internal-linkage>` check to insert ``static``
289-
keyword before type qualifiers such as ``const`` and ``volatile`` and fix
290-
false positives for function declaration without body and fix false positives
291-
for C++20 export declarations and fix false positives for global scoped
289+
keyword before type qualifiers such as ``const`` and ``volatile``. Also, fix
290+
false positives for function declaration without body, C++20 consteval
291+
functions, C++20 export declarations, and global scoped
292292
overloaded ``operator new`` and ``operator delete``.
293293

294294
- Improved :doc:`modernize-avoid-c-arrays
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %check_clang_tidy -std=c++20 %s misc-use-internal-linkage %t -- -- -I%S/Inputs/use-internal-linkage
2+
3+
consteval void gh122096() {}
4+
5+
constexpr void cxf() {}
6+
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: function 'cxf'
7+
// CHECK-FIXES: static constexpr void cxf() {}

0 commit comments

Comments
 (0)