Skip to content

[QoI] warn about non-static, non-inline, non-template function definitions in header files #10376

@zygoloid

Description

@zygoloid
mannequin
Bugzilla Link 10004
Version trunk
OS Linux
CC @gnzlbg

Extended Description

clang -Wall -Wextra produces no warnings for this:

// a.h
struct S {
void f();
};

void S::f() {}

// a.cpp
#include "a.h"
void g() {
S s;
s.f();
}

This issue is a particular efficiency drain since it doesn't manifest until link time, and requires a rebuild of all includers of the header.

Ideally, any definition which wholly comes from a header file and produces a non-weak symbol should warn. We'll need to be careful to weed out macros defined in the main source file and expanded in #included files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions