Skip to content

fixes "double friend" issue #918

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

fixes "double friend" issue #918

wants to merge 2 commits into from

Conversation

cjdb
Copy link

@cjdb cjdb commented May 17, 2023

C++ specifiers can go in almost any order, but the friend logic was overlooking this for some cases. In particular, constexpr friend wasn't being accounted for.

The following cases have been verified.

struct cat {
  /// Checks if the cats are the same.
  constexpr friend bool operator==(cat x, cat y)
  {
    return true;
  }

  /// Makes the cat cute.
  friend void make_cute(cat c)
  {
  }

  /// Makes the cat cuter.
  friend void make_cuter(cat c);

  /// Makes the cat the cutest.
  constexpr friend void make_cutest(cat c);
};

/// This won't be picked up.
constexpr void make_cutest(cat c)
{}

Fixes #916

C++ specifiers can go in almost any order, but the `friend` logic was
overlooking this for some cases. In particular, `constexpr friend`
wasn't being accounted for.

The following cases have been verified.

```cpp
struct cat {
  /// Checks if the cats are the same.
  constexpr friend bool operator==(cat x, cat y)
  {
    return true;
  }

  /// Makes the cat cute.
  friend void make_cute(cat c)
  {
  }

  /// Makes the cat cuter.
  friend void make_cuter(cat c);

  /// Makes the cat the cutest.
  constexpr friend void make_cutest(cat c);
};

/// This won't be picked up.
constexpr void make_cutest(cat c)
{}
```

Fixes breathe-doc#916
@cjdb
Copy link
Author

cjdb commented May 17, 2023

Is there a way to add unit tests? I haven't worked out how to do that for this project yet :(

@emilydolson
Copy link
Contributor

Since I have a vested interest in this getting merged (in that I would love for it to be fixed, and also for the fix for #917 to get merged), I messed around with the testing infrastructure and I wrote what I believe is a sufficient test for this fix. @cjdb, I'm sending it to you as a PR on the friend branch of your fork.

@emilydolson emilydolson mentioned this pull request Jun 20, 2023
@bdice
Copy link

bdice commented Apr 24, 2025

Hi, I was wondering if this could be reviewed and merged. Are there next steps still needed or is this waiting for a maintainer?

Comment on lines +1989 to +1992
# In Doxygen up to somewhere between 1.8.17 to exclusive 1.9.1
# the 'friend' part is also left in the type.
# See also: #767, #916
typ = re.sub(r"(^|\s+)friend(\s+)", r"\1\2", typ)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now require Doxygen 1.9.2+. Is this still relevant?

@AA-Turner
Copy link
Collaborator

Happy to merge if conflicts are resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

inline constexpr friends inject extra keywords
4 participants