[clang-tools-extra] [clang-tidy] Fix spurious errors from builtin macros in modernize-use-trailing-return-type (PR #184022)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Mar 1 11:20:06 PST 2026
================
@@ -487,6 +487,15 @@ decltype(COMMAND_LINE_INT{}) h21();
// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
// CHECK-FIXES: auto h21() -> decltype(COMMAND_LINE_INT{});
+// Builtin macros like __has_feature are registered as object-like macros but
+// require function-like syntax when expanded. Ensure the check does not cause
+// spurious "missing '(' after '__has_feature'" errors when they appear in the
+// raw lex span of a function return type.
+const decltype(__has_feature(cxx_constexpr)) h22();
+// CHECK-MESSAGES: :[[@LINE-1]]:46: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
+const decltype(__has_builtin(__builtin_expect)) h23();
+// CHECK-MESSAGES: :[[@LINE-1]]:49: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
----------------
vadikmironov wrote:
Done, check() emits the warning, but no fixit and hence checking for the unchanged function.
https://github.com/llvm/llvm-project/pull/184022
More information about the cfe-commits
mailing list