From 40d4acafcab79ab3c7f7378a7d84b933baaa09c3 Mon Sep 17 00:00:00 2001 From: MikePopoloski Date: Sat, 20 Jan 2024 14:47:22 -0500 Subject: [PATCH] Add docs to clone and deepClone methods --- include/slang/syntax/SyntaxNode.h | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/include/slang/syntax/SyntaxNode.h b/include/slang/syntax/SyntaxNode.h index 42f811fb0..e34858edc 100644 --- a/include/slang/syntax/SyntaxNode.h +++ b/include/slang/syntax/SyntaxNode.h @@ -158,14 +158,33 @@ class SLANG_EXPORT SyntaxNode { TokenOrSyntax getChild(size_t index); }; -SLANG_EXPORT SyntaxNode* clone(const SyntaxNode&, BumpAllocator&); -SLANG_EXPORT SyntaxNode* deepClone(const SyntaxNode&, BumpAllocator&); - +/// @brief Performs a shallow clone of the given syntax node. +/// +/// All members will be simply copied to the new instance. +/// The instance will be allocated with the provided allocator. +SLANG_EXPORT SyntaxNode* clone(const SyntaxNode& node, BumpAllocator& alloc); + +/// @brief Performs a deep clone of the given syntax node. +/// +/// All members will be cloned recursively to create a complete new +/// copy of the syntax tree. All cloned instances will be allocated +/// with the provided allocator. +SLANG_EXPORT SyntaxNode* deepClone(const SyntaxNode& node, BumpAllocator& alloc); + +/// @brief Performs a shallow clone of the given syntax node. +/// +/// All members will be simply copied to the new instance. +/// The instance will be allocated with the provided allocator. template T> T* clone(const T& node, BumpAllocator& alloc) { return static_cast(clone(static_cast(node), alloc)); } +/// @brief Performs a deep clone of the given syntax node. +/// +/// All members will be cloned recursively to create a complete new +/// copy of the syntax tree. All cloned instances will be allocated +/// with the provided allocator. template T> T* deepClone(const T& node, BumpAllocator& alloc) { return static_cast(deepClone(static_cast(node), alloc));