Author: Benjamin Kramer Date: 2022-02-20T12:12:39+01:00 New Revision: 51c0650f6ba8128fb07036b4be8512bb5f727c1a
URL: https://github.com/llvm/llvm-project/commit/51c0650f6ba8128fb07036b4be8512bb5f727c1a DIFF: https://github.com/llvm/llvm-project/commit/51c0650f6ba8128fb07036b4be8512bb5f727c1a.diff LOG: Unionize clang::DynTypedNodeList. NFC. Added: Modified: clang/include/clang/AST/ParentMapContext.h Removed: ################################################################################ diff --git a/clang/include/clang/AST/ParentMapContext.h b/clang/include/clang/AST/ParentMapContext.h index 2edbc987850d2..3c2e2f9640ca3 100644 --- a/clang/include/clang/AST/ParentMapContext.h +++ b/clang/include/clang/AST/ParentMapContext.h @@ -90,29 +90,27 @@ class TraversalKindScope { /// Container for either a single DynTypedNode or for an ArrayRef to /// DynTypedNode. For use with ParentMap. class DynTypedNodeList { - llvm::AlignedCharArrayUnion<DynTypedNode, ArrayRef<DynTypedNode>> Storage; + union { + DynTypedNode SingleNode; + ArrayRef<DynTypedNode> Nodes; + }; bool IsSingleNode; public: DynTypedNodeList(const DynTypedNode &N) : IsSingleNode(true) { - new (&Storage) DynTypedNode(N); + new (&SingleNode) DynTypedNode(N); } DynTypedNodeList(ArrayRef<DynTypedNode> A) : IsSingleNode(false) { - new (&Storage) ArrayRef<DynTypedNode>(A); + new (&Nodes) ArrayRef<DynTypedNode>(A); } const DynTypedNode *begin() const { - if (!IsSingleNode) - return reinterpret_cast<const ArrayRef<DynTypedNode> *>(&Storage) - ->begin(); - return reinterpret_cast<const DynTypedNode *>(&Storage); + return !IsSingleNode ? Nodes.begin() : &SingleNode; } const DynTypedNode *end() const { - if (!IsSingleNode) - return reinterpret_cast<const ArrayRef<DynTypedNode> *>(&Storage)->end(); - return reinterpret_cast<const DynTypedNode *>(&Storage) + 1; + return !IsSingleNode ? Nodes.end() : &SingleNode + 1; } size_t size() const { return end() - begin(); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits