@@ -335,7 +335,7 @@ class SDKNode {
335
335
ArrayRef<NodeUniquePtr> getChildren () const ;
336
336
void collectChildren (NodeVector &Bucket) const ;
337
337
unsigned getChildIndex (NodePtr Child) const ;
338
- NodePtr getOnlyChild () const ;
338
+ const SDKNode* getOnlyChild () const ;
339
339
template <typename T> const T *getAs () const ;
340
340
template <typename T> T *getAs ();
341
341
};
@@ -418,9 +418,14 @@ class SDKNodeTypeNameAlias : public SDKNodeType {
418
418
public:
419
419
SDKNodeTypeNameAlias (SDKNodeInitInfo Info) : SDKNodeType(Info,
420
420
SDKNodeKind::TypeNameAlias) {}
421
+ const SDKNodeType *getUnderlyingType () const ;
421
422
static bool classof (const SDKNode *N);
422
423
};
423
424
425
+ const SDKNodeType *SDKNodeTypeNameAlias::getUnderlyingType () const {
426
+ return getOnlyChild ()->getAs <SDKNodeType>();
427
+ }
428
+
424
429
template <typename T> const T *
425
430
SDKNode::getAs () const {
426
431
if (T::classof (this ))
@@ -440,7 +445,7 @@ unsigned SDKNode::getChildIndex(NodePtr Child) const {
440
445
[&](const NodeUniquePtr &P) { return P.get () == Child; }) - Children.begin ();
441
446
}
442
447
443
- NodePtr SDKNode::getOnlyChild () const {
448
+ const SDKNode* SDKNode::getOnlyChild () const {
444
449
assert (Children.size () == 1 && " more that one child." );
445
450
return (*Children.begin ()).get ();
446
451
}
@@ -876,6 +881,15 @@ NodeUniquePtr SDKNode::constructSDKNode(llvm::yaml::MappingNode *Node) {
876
881
}
877
882
878
883
bool SDKNode::operator ==(const SDKNode &Other) const {
884
+ auto *LeftAlias = dyn_cast<SDKNodeTypeNameAlias>(this );
885
+ auto *RightAlias = dyn_cast<SDKNodeTypeNameAlias>(&Other);
886
+ if (LeftAlias || RightAlias) {
887
+ // Comparing the underlying types if any of the inputs are alias.
888
+ const SDKNode *Left = LeftAlias ? LeftAlias->getUnderlyingType () : this ;
889
+ const SDKNode *Right = RightAlias ? RightAlias->getUnderlyingType () : &Other;
890
+ return *Left == *Right;
891
+ }
892
+
879
893
if (getKind () != Other.getKind ())
880
894
return false ;
881
895
0 commit comments