[clang-tools-extra] [clang-tidy][use-internal-linkage] fix false positive for consteval function (PR #122141)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 8 08:48:57 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-tidy
Author: None (maflcko)
<details>
<summary>Changes</summary>
Fixes https://github.com/llvm/llvm-project/issues/122096
---
Full diff: https://github.com/llvm/llvm-project/pull/122141.diff
3 Files Affected:
- (modified) clang-tools-extra/clang-tidy/misc/UseInternalLinkageCheck.cpp (+1-1)
- (modified) clang-tools-extra/docs/ReleaseNotes.rst (+3-3)
- (added) clang-tools-extra/test/clang-tidy/checkers/misc/use-internal-linkage-consteval.cpp (+3)
``````````diff
diff --git a/clang-tools-extra/clang-tidy/misc/UseInternalLinkageCheck.cpp b/clang-tools-extra/clang-tidy/misc/UseInternalLinkageCheck.cpp
index 1e0f398a4a560b..4778182944abda 100644
--- a/clang-tools-extra/clang-tidy/misc/UseInternalLinkageCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/UseInternalLinkageCheck.cpp
@@ -125,7 +125,7 @@ void UseInternalLinkageCheck::registerMatchers(MatchFinder *Finder) {
exportDecl()))))));
Finder->addMatcher(
functionDecl(Common, hasBody(),
- unless(anyOf(cxxMethodDecl(),
+ unless(anyOf(cxxMethodDecl(), isConsteval(),
isAllocationOrDeallocationOverloadedFunction(),
isMain())))
.bind("fn"),
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst
index 94e15639c4a92e..8bea7e89d94173 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -286,9 +286,9 @@ Changes in existing checks
- Improved :doc:`misc-use-internal-linkage
<clang-tidy/checks/misc/use-internal-linkage>` check to insert ``static``
- keyword before type qualifiers such as ``const`` and ``volatile`` and fix
- false positives for function declaration without body and fix false positives
- for C++20 export declarations and fix false positives for global scoped
+ keyword before type qualifiers such as ``const`` and ``volatile``. Also, fix
+ false positives for function declaration without body, C++20 consteval
+ functions, C++20 export declarations, and global scoped
overloaded ``operator new`` and ``operator delete``.
- Improved :doc:`modernize-avoid-c-arrays
diff --git a/clang-tools-extra/test/clang-tidy/checkers/misc/use-internal-linkage-consteval.cpp b/clang-tools-extra/test/clang-tidy/checkers/misc/use-internal-linkage-consteval.cpp
new file mode 100644
index 00000000000000..25674a2be4c918
--- /dev/null
+++ b/clang-tools-extra/test/clang-tidy/checkers/misc/use-internal-linkage-consteval.cpp
@@ -0,0 +1,3 @@
+// RUN: %check_clang_tidy -std=c++20 %s misc-use-internal-linkage %t -- -- -I%S/Inputs/use-internal-linkage
+
+consteval void gh122096() {}
``````````
</details>
https://github.com/llvm/llvm-project/pull/122141
More information about the cfe-commits
mailing list