Skip to content
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

inline constexpr friends inject extra keywords #916

Open
cjdb opened this issue May 16, 2023 · 4 comments · May be fixed by #918
Open

inline constexpr friends inject extra keywords #916

cjdb opened this issue May 16, 2023 · 4 comments · May be fixed by #918

Comments

@cjdb
Copy link

cjdb commented May 16, 2023

Steps to reproduce

  1. Follow Sy Brand's tutorial for setting up Breathe.
  2. Add the following to CatCutifier.h
/**
  A fluffy feline
*/
struct cat {
  /**
    Make this cat look super cute
  */
  void make_cute();

  /// some docs
  constexpr friend bool operator==(cat const x, int const y)
  {
    return true;
  }
};

Expected output

constexpr friend bool operator==(cat const x, int const y)

  some docs

Actual output

inline friend constexpr friend bool operator== (cat const x, int const y)

  some docs

inline should not be present at all, and friend should only appear once.

@vermeeren
Copy link
Collaborator

@cjdb Could you also post the Doxygen XML definition for the operator==, curious to see what I looks like.

@cjdb
Copy link
Author

cjdb commented May 16, 2023

Not entirely sure what you're after, so I've bundled everything from my doxygen/xml. I also checked the HTML and didn't see extra keywords.
xml.zip

@cjdb
Copy link
Author

cjdb commented May 16, 2023

I noticed while looking into #917 that friend is unconditionally being inserted if something is a friend. I'm not sure why it being constexpr impacts this, but commenting that line out seems to fix it (I haven't tested to see what happens in situations that aren't like the one above yet).

if node.kind == "friend":
elements.append("friend")

Update: it looks as if friend constexpr works as intended, but constexpr friend does not.

cjdb added a commit to cjdb/breathe that referenced this issue 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.

```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 added a commit to cjdb/breathe that referenced this issue 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.

```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 cjdb linked a pull request May 17, 2023 that will close this issue
@vyasr
Copy link

vyasr commented Nov 9, 2023

Hey everyone, thanks for making a great tool here in Breathe! @vermeeren any chance of getting #918 merged and into a release? It looks like this issue (and #917) have pending fixes that could go in.

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 a pull request may close this issue.

3 participants