diff --git a/clang/include/clang/AST/ParentMapContext.h b/clang/include/clang/AST/ParentMapContext.h index 2edbc987850d23..3c2e2f9640ca36 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> Storage; + union { + DynTypedNode SingleNode; + ArrayRef Nodes; + }; bool IsSingleNode; public: DynTypedNodeList(const DynTypedNode &N) : IsSingleNode(true) { - new (&Storage) DynTypedNode(N); + new (&SingleNode) DynTypedNode(N); } DynTypedNodeList(ArrayRef A) : IsSingleNode(false) { - new (&Storage) ArrayRef(A); + new (&Nodes) ArrayRef(A); } const DynTypedNode *begin() const { - if (!IsSingleNode) - return reinterpret_cast *>(&Storage) - ->begin(); - return reinterpret_cast(&Storage); + return !IsSingleNode ? Nodes.begin() : &SingleNode; } const DynTypedNode *end() const { - if (!IsSingleNode) - return reinterpret_cast *>(&Storage)->end(); - return reinterpret_cast(&Storage) + 1; + return !IsSingleNode ? Nodes.end() : &SingleNode + 1; } size_t size() const { return end() - begin(); }