[clang-tools-extra] [clang-tidy] Move `ClassifiedToken` to cpp file (PR #196820)
David Stone via cfe-commits
cfe-commits at lists.llvm.org
Sun May 10 10:42:12 PDT 2026
https://github.com/davidstone created https://github.com/llvm/llvm-project/pull/196820
`ClassifiedToken` is used in only the implementation of `UseTrailingReturnTypeCheck`. Move it into the unnamed namespace of the cpp file instead of it being in the header.
>From 232aa7855916ecb6d3ed175bf8711ae469675524 Mon Sep 17 00:00:00 2001
From: David Stone <davidfromonline at gmail.com>
Date: Sun, 10 May 2026 11:41:27 -0600
Subject: [PATCH] [clang-tidy] Move `ClassifiedToken` to cpp file
`ClassifiedToken` is used in only the implementation of `UseTrailingReturnTypeCheck`. Move it into the unnamed namespace of the cpp file instead of it being in the header.
---
.../modernize/UseTrailingReturnTypeCheck.cpp | 10 ++++++++++
.../clang-tidy/modernize/UseTrailingReturnTypeCheck.h | 6 ------
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
index ea43cd6c42222..8bc06afaeb33c 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
@@ -205,6 +205,16 @@ static bool isSpecifier(Token T) {
tok::kw_static, tok::kw_friend, tok::kw_virtual);
}
+namespace {
+
+struct ClassifiedToken {
+ Token T;
+ bool IsQualifier;
+ bool IsSpecifier;
+};
+
+} // namespace
+
static std::optional<ClassifiedToken>
classifyToken(const FunctionDecl &F, Preprocessor &PP, Token Tok) {
ClassifiedToken CT;
diff --git a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.h b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.h
index 4aa1adaf30db5..05a8952f03700 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.h
+++ b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.h
@@ -14,12 +14,6 @@
namespace clang::tidy::modernize {
-struct ClassifiedToken {
- Token T;
- bool IsQualifier;
- bool IsSpecifier;
-};
-
/// Rewrites function signatures to use a trailing return type.
///
/// For the user-facing documentation see:
More information about the cfe-commits
mailing list