Skip to content

hasName AST matcher is confused by extern "C" in namespace #41538

@Boddlnagg

Description

@Boddlnagg
Bugzilla Link 42193
Resolution FIXED
Resolved on Feb 27, 2020 04:13
Version unspecified
OS Windows NT
Blocks #43900
CC @zmodem,@zygoloid
Fixed by commit(s) rG16cabf278fc8c14d415e677ce0bc40d46a6de30d

Extended Description

Given the following code:

namespace foo {
extern "C" void test() {}
}

... I expect an AST matcher declared as functionDecl(hasName("::foo::test")) to match the function, but functionDecl(hasName("::test")) should not match. However, the opposite is the case. (see the example on Compiler Explorer: http://ce.steveire.com/z/VDTi_g)

When I do this locally with a build with assertions, I get an assertion failure at

assert(matchesNodeFullFast(Node) == matchesNodeFullSlow(Node));
, so I think the problem is that matchesNodeFullFast does not correctly handle extern "C" functions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclang: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