llvm / llvm/llvm-project

libclang : Friend class incorrectly TypeRefed at global scope

Open
#197,642 4 comments 0 reactions 0 assignees View on GitHub
clang:as-a-library
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Consider the following code:

```c++
struct FriendFoo
{
friend class FriendBar;
};

class FriendBar{};
```

the **friend** statement TypeRefs itself (`class FriendBar:3:18`) instead of TypeRefing the class. `c-index-test` output.

```
// CHECK: friend.cpp:1:8: StructDecl=FriendFoo:1:8 (Definition) Extent=[1:1 - 4:2]
// CHECK: friend.cpp:3:12: FriendDecl=:3:12 Extent=[3:5 - 3:27] [access=public]
// CHECK: friend.cpp:3:18: TypeRef=class FriendBar:3:18 Extent=[3:18 - 3:27]
// CHECK: friend.cpp:6:7: ClassDecl=FriendBar:6:7 (Definition) Extent=[6:1 - 6:18]
```

This regressed in https://github.com/llvm/llvm-project/commit/91cdd35008e9ab32dffb7e401cdd7313b3461892 from TypeRefing `class FriendBar:6:7`:
```
// CHECK: friend.cpp:1:8: StructDecl=FriendFoo:1:8 (Definition) Extent=[1:1 - 4:2]
// CHECK: friend.cpp:3:12: FriendDecl=:3:12 Extent=[3:5 - 3:27] [access=public]
// CHECK: friend.cpp:3:18: TypeRef=class FriendBar:6:7 Extent=[3:18 - 3:27]
// CHECK: friend.cpp:6:7: ClassDecl=FriendBar:6:7 (Definition) Extent=[6:1 - 6:18]
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.