Skip to content

clang-query: matchesName AST matcher insists on "::" prefix #47223

Open
@real-or-random

Description

@real-or-random
Bugzilla Link 47879
Version unspecified
OS All
CC @AaronBallman

Extended Description

$ echo "void foo(void) { }" > foo.c

$ clang-query foo.c -c 'match functionDecl(matchesName("^foo"))'
0 matches.

$ clang-query foo.c -c 'match functionDecl(matchesName("^::foo"))'

Match #​1:

/tmp/foo.c:1:1: note: "root" binds here
void foo(void) { }
^~~~~~~~~~~~~~~~~~
1 match.

This is clear from the code:

std::string FullNameString = "::" + Node.getQualifiedNameAsString();

But it's at least unexpected, in particular for C code.

The matcher seems to be correctly used in a few places within the LLVM codebase. If this is the intended behavior, then the documentation is wrong.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions