[clang-tools-extra] [clang-doc][NFC] Use destructuring in Mapper.cpp (PR #135515)
Paul Kirth via cfe-commits
cfe-commits at lists.llvm.org
Sat Apr 12 19:21:12 PDT 2025
https://github.com/ilovepi created https://github.com/llvm/llvm-project/pull/135515
Destructuring makes the intent a bit clearer over first/second.
>From 208748cce41c402f6c82e5132887eeafdff70745 Mon Sep 17 00:00:00 2001
From: Paul Kirth <paulkirth at google.com>
Date: Sat, 12 Apr 2025 19:19:19 -0700
Subject: [PATCH] [clang-doc][NFC] Use destructuring in Mapper.cpp
Destructuring makes the intent a bit clearer over first/second.
---
clang-tools-extra/clang-doc/Mapper.cpp | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/clang-tools-extra/clang-doc/Mapper.cpp b/clang-tools-extra/clang-doc/Mapper.cpp
index 6c90db03424c6..2a10c146b4a91 100644
--- a/clang-tools-extra/clang-doc/Mapper.cpp
+++ b/clang-tools-extra/clang-doc/Mapper.cpp
@@ -59,18 +59,18 @@ bool MapASTVisitor::mapDecl(const T *D, bool IsDefinition) {
bool IsFileInRootDir;
llvm::SmallString<128> File =
getFile(D, D->getASTContext(), CDCtx.SourceRoot, IsFileInRootDir);
- auto I = serialize::emitInfo(D, getComment(D, D->getASTContext()),
- getLine(D, D->getASTContext()), File,
- IsFileInRootDir, CDCtx.PublicOnly);
-
- // A null in place of I indicates that the serializer is skipping this decl
- // for some reason (e.g. we're only reporting public decls).
- if (I.first)
- CDCtx.ECtx->reportResult(llvm::toHex(llvm::toStringRef(I.first->USR)),
- serialize::serialize(I.first));
- if (I.second)
- CDCtx.ECtx->reportResult(llvm::toHex(llvm::toStringRef(I.second->USR)),
- serialize::serialize(I.second));
+ auto [Child, Parent] = serialize::emitInfo(
+ D, getComment(D, D->getASTContext()), getLine(D, D->getASTContext()),
+ File, IsFileInRootDir, CDCtx.PublicOnly);
+
+ // A null in place of a valid Info indicates that the serializer is skipping
+ // this decl for some reason (e.g. we're only reporting public decls).
+ if (Child)
+ CDCtx.ECtx->reportResult(llvm::toHex(llvm::toStringRef(Child->USR)),
+ serialize::serialize(Child));
+ if (Parent)
+ CDCtx.ECtx->reportResult(llvm::toHex(llvm::toStringRef(Parent->USR)),
+ serialize::serialize(Parent));
return true;
}
More information about the cfe-commits
mailing list