Skip to content

Commit f996709

Browse files
Merge pull request #526 from ceresgalax/odr
Add OverloadedDeclRef
2 parents 356fea3 + 4090c68 commit f996709

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright (c) .NET Foundation and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
2+
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using ClangSharp.Interop;
7+
using static ClangSharp.Interop.CXCursorKind;
8+
9+
namespace ClangSharp;
10+
11+
public sealed class OverloadedDeclRef : Ref
12+
{
13+
private readonly Lazy<IEnumerable<Decl>> _overloadedDecls;
14+
15+
internal OverloadedDeclRef(CXCursor handle) : base(handle, CXCursor_OverloadedDeclRef)
16+
{
17+
_overloadedDecls = new Lazy<IEnumerable<Decl>>(() => {
18+
uint num = Handle.NumOverloadedDecls;
19+
return Enumerable.Range(0, (int)num)
20+
.Select(i => Handle.GetOverloadedDecl((uint)i))
21+
.Select(c => TranslationUnit.GetOrCreate<Decl>(c))
22+
.ToArray();
23+
});
24+
}
25+
26+
public IEnumerable<Decl> OverloadedDecls => _overloadedDecls.Value;
27+
}

sources/ClangSharp/Cursors/Refs/Ref.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ private protected Ref(CXCursor handle, CXCursorKind expectedCursorKind) : base(h
3434
break;
3535
}
3636

37+
case CXCursor_OverloadedDeclRef:
38+
{
39+
result = new OverloadedDeclRef(handle);
40+
break;
41+
}
42+
3743
case CXCursor_ObjCSuperClassRef:
3844
case CXCursor_ObjCProtocolRef:
3945
case CXCursor_ObjCClassRef:
@@ -42,7 +48,6 @@ private protected Ref(CXCursor handle, CXCursorKind expectedCursorKind) : base(h
4248
case CXCursor_NamespaceRef:
4349
case CXCursor_MemberRef:
4450
case CXCursor_LabelRef:
45-
case CXCursor_OverloadedDeclRef:
4651
case CXCursor_VariableRef:
4752
{
4853
result = new Ref(handle, handle.Kind);

0 commit comments

Comments
 (0)