Skip to content

[clang-tidy] readability-redundant-inline-specifier: with modules, inline on in-class member function definitions is not always redundant #148289

Open
@localspook

Description

@localspook

Consider this class:

struct s {
    void f() {}
};

In a non-module world, f is implicitly inline, and writing the keyword is redundant.
But C++20 adopted P1779, which changes the semantics of this code: when s is not attached to the global module, f is not inline; if you want it to be, you have to say so explicitly. This does not apply to defaulted member functions however:

struct s {
    inline s() = default; // Still redundant.
};

So I believe this check should not trigger on non-defaulted functions outside the global module. (We may even want to add a check like modernize-modules that adds inline to ease the transition to modules.)

Godbolt: https://godbolt.org/z/Gv9YGzq9e

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions