Skip to content

-Wunused-function false positive for the alias attribute with MicrosoftDemangle #88825

Open
@MaskRay

Description

@MaskRay

Clang supports the alias attribute from GCC.
While primarily used for C projects on ELF platforms and possibly also windows-gnu, Clang accepts the alias attribute for windows-msvc targets as well.

This scenario is more like "the feature is generic, let's make it available for everyone" rather than "there are active users of this for windows-msvc".
After removing some false positive results from rg '\(_?_?alias|::alias' -l | xargs grep -l windows, there is nearly no test.
I recently added one in clang/test/Sema/alias-unused-win.cpp.

The -Wunused-function diagnostic does not know how to connect an alias target to an internal linkage declaration, so we will get a false positive.

static int f1() { return 42; } // cxx-warning{{unused function 'f1'}}
int g1() __attribute__((alias("?f1@@YAHXZ")));

This can be fixed if #88823 is available.

Note: #88593 is about whether we should mangle an internal linkage function in extern "C" (static wins, no language linkage)

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions