[clang-tools-extra] [clang-doc][NFC] Use destructuring in Mapper.cpp (PR #135515)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Apr 12 19:38:18 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-tools-extra
Author: Paul Kirth (ilovepi)
<details>
<summary>Changes</summary>
Destructuring makes the intent a bit clearer over first/second.
---
Full diff: https://github.com/llvm/llvm-project/pull/135515.diff
1 Files Affected:
- (modified) clang-tools-extra/clang-doc/Mapper.cpp (+12-12)
``````````diff
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;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/135515
More information about the cfe-commits
mailing list