[llvm-branch-commits] [clang-tools-extra] [clang-doc] Use static functions over the anonymous namespace (PR #170221)
Paul Kirth via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Dec 3 14:09:22 PST 2025
https://github.com/ilovepi updated https://github.com/llvm/llvm-project/pull/170221
>From 05abefd202f401436b20f27e653cf9d2ea13bc63 Mon Sep 17 00:00:00 2001
From: Paul Kirth <paulkirth at google.com>
Date: Tue, 25 Nov 2025 16:29:39 -0800
Subject: [PATCH] [clang-doc] Use static functions over the anonymous namespace
---
clang-tools-extra/clang-doc/Representation.cpp | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/clang-tools-extra/clang-doc/Representation.cpp b/clang-tools-extra/clang-doc/Representation.cpp
index ffa0eaa5a0a38..a2e6b305c2986 100644
--- a/clang-tools-extra/clang-doc/Representation.cpp
+++ b/clang-tools-extra/clang-doc/Representation.cpp
@@ -82,12 +82,10 @@ llvm::StringRef commentKindToString(CommentKind Kind) {
llvm_unreachable("Unhandled CommentKind");
}
-namespace {
-
const SymbolID EmptySID = SymbolID();
template <typename T>
-llvm::Expected<std::unique_ptr<Info>>
+static llvm::Expected<std::unique_ptr<Info>>
reduce(std::vector<std::unique_ptr<Info>> &Values) {
if (Values.empty() || !Values[0])
return llvm::createStringError(llvm::inconvertibleErrorCode(),
@@ -102,7 +100,7 @@ reduce(std::vector<std::unique_ptr<Info>> &Values) {
// Return the index of the matching child in the vector, or -1 if merge is not
// necessary.
template <typename T>
-int getChildIndexIfExists(std::vector<T> &Children, T &ChildToMerge) {
+static int getChildIndexIfExists(std::vector<T> &Children, T &ChildToMerge) {
for (unsigned long I = 0; I < Children.size(); I++) {
if (ChildToMerge.USR == Children[I].USR)
return I;
@@ -111,8 +109,8 @@ int getChildIndexIfExists(std::vector<T> &Children, T &ChildToMerge) {
}
template <typename T>
-void reduceChildren(std::vector<T> &Children,
- std::vector<T> &&ChildrenToMerge) {
+static void reduceChildren(std::vector<T> &Children,
+ std::vector<T> &&ChildrenToMerge) {
for (auto &ChildToMerge : ChildrenToMerge) {
int MergeIdx = getChildIndexIfExists(Children, ChildToMerge);
if (MergeIdx == -1) {
@@ -123,8 +121,6 @@ void reduceChildren(std::vector<T> &Children,
}
}
-} // namespace
-
// Dispatch function.
llvm::Expected<std::unique_ptr<Info>>
mergeInfos(std::vector<std::unique_ptr<Info>> &Values) {
More information about the llvm-branch-commits
mailing list