Skip to content

Commit

Permalink
Merge pull request #526 from ceresgalax/odr
Browse files Browse the repository at this point in the history
Add OverloadedDeclRef
  • Loading branch information
tannergooding committed Feb 4, 2024
2 parents 356fea3 + 4090c68 commit f996709
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
27 changes: 27 additions & 0 deletions sources/ClangSharp/Cursors/Refs/OverloadedDeclRef.cs
@@ -0,0 +1,27 @@
// Copyright (c) .NET Foundation and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.

using System;
using System.Collections.Generic;
using System.Linq;
using ClangSharp.Interop;
using static ClangSharp.Interop.CXCursorKind;

namespace ClangSharp;

public sealed class OverloadedDeclRef : Ref
{
private readonly Lazy<IEnumerable<Decl>> _overloadedDecls;

internal OverloadedDeclRef(CXCursor handle) : base(handle, CXCursor_OverloadedDeclRef)
{
_overloadedDecls = new Lazy<IEnumerable<Decl>>(() => {
uint num = Handle.NumOverloadedDecls;
return Enumerable.Range(0, (int)num)
.Select(i => Handle.GetOverloadedDecl((uint)i))
.Select(c => TranslationUnit.GetOrCreate<Decl>(c))
.ToArray();
});
}

public IEnumerable<Decl> OverloadedDecls => _overloadedDecls.Value;
}
7 changes: 6 additions & 1 deletion sources/ClangSharp/Cursors/Refs/Ref.cs
Expand Up @@ -34,6 +34,12 @@ internal static new Ref Create(CXCursor handle)
break;
}

case CXCursor_OverloadedDeclRef:
{
result = new OverloadedDeclRef(handle);
break;
}

case CXCursor_ObjCSuperClassRef:
case CXCursor_ObjCProtocolRef:
case CXCursor_ObjCClassRef:
Expand All @@ -42,7 +48,6 @@ internal static new Ref Create(CXCursor handle)
case CXCursor_NamespaceRef:
case CXCursor_MemberRef:
case CXCursor_LabelRef:
case CXCursor_OverloadedDeclRef:
case CXCursor_VariableRef:
{
result = new Ref(handle, handle.Kind);
Expand Down

0 comments on commit f996709

Please sign in to comment.