https://github.com/maflcko created https://github.com/llvm/llvm-project/pull/122141
Fixes https://github.com/llvm/llvm-project/issues/122096 >From 92e175391c150d53f887e24125a7f80c26fc630e Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_...@721217.xyz> Date: Wed, 8 Jan 2025 17:46:47 +0100 Subject: [PATCH] [clang-tidy][use-internal-linkage] fix false positive for consteval function --- .../clang-tidy/misc/UseInternalLinkageCheck.cpp | 2 +- clang-tools-extra/docs/ReleaseNotes.rst | 6 +++--- .../checkers/misc/use-internal-linkage-consteval.cpp | 3 +++ 3 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 clang-tools-extra/test/clang-tidy/checkers/misc/use-internal-linkage-consteval.cpp 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() {} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits