diff --git a/lib/Support/ItaniumManglingCanonicalizer.cpp b/lib/Support/ItaniumManglingCanonicalizer.cpp index 7023305774e..ca63c6d1c7d 100644 --- a/lib/Support/ItaniumManglingCanonicalizer.cpp +++ b/lib/Support/ItaniumManglingCanonicalizer.cpp @@ -104,8 +104,19 @@ class FoldingNodeAllocator { public: void reset() {} - template - std::pair getOrCreateNode(bool CreateNewNodes, Args &&...As) { + template + std::pair getOrCreateNode(bool CreateNewNodes, Args &&... As) { + // FIXME: Don't canonicalize forward template references for now, because + // they contain state (the resolved template node) that's not known at their + // point of creation. + if (std::is_same::value) { + // Note that we don't use if-constexpr here and so we must still write + // this code in a generic form. + return {new (RawAlloc.Allocate(sizeof(T), alignof(T))) + T(std::forward(As)...), + true}; + } + llvm::FoldingSetNodeID ID; profileCtor(ID, NodeKind::Kind, As...); @@ -136,19 +147,6 @@ public: } }; -// FIXME: Don't canonicalize forward template references for now, because they -// contain state (the resolved template node) that's not known at their point -// of creation. -template<> -std::pair -FoldingNodeAllocator::getOrCreateNode(bool, - size_t &Index) { - return {new (RawAlloc.Allocate(sizeof(ForwardTemplateReference), - alignof(ForwardTemplateReference))) - ForwardTemplateReference(Index), - true}; -} - class CanonicalizerAllocator : public FoldingNodeAllocator { Node *MostRecentlyCreated = nullptr; Node *TrackedNode = nullptr;