Skip to content

Wrong source location for friend static method #22835

@Abramo-Bagnara

Description

@Abramo-Bagnara
Bugzilla Link 22461
Version trunk
OS Linux
CC @DougGregor

Extended Description

For the following program:

struct A {
  template <typename T, typename U> static void create (U) {}
};

struct B {
  friend void A::create <B, const char *> (const char *);
};

int main() {
  A::create<B>("test");
}

I get this AST for friend declaration:

| `-FriendDecl 0x7f801d0 <line:2:37, col:61> line:6:18
|   `-CXXMethodDecl 0x7f7fc90 parent 0x7f3a0e0 prev 0x7f80000 <line:2:37, col:61> line:6:18 used create 'void (const char *)'
|     |-TemplateArgument type 'struct B'
|     |-TemplateArgument type 'const char *'
|     |-ParmVarDecl 0x7f7fbd0 <col:44, col:55> col:56 'const char *'
|     `-CompoundStmt 0x7f7f988 <line:2:60, col:61>

As can be observed from the dump above the friend method AST is not tied to source but it is a reference to instantiated method.

As a consequence the body is present and locations refers the templated function and not the friend method declaration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillac++clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second party

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions