Skip to content

Some Matchers return Blank match with diag output #51810

Open
@Dylan-Brotherston

Description

@Dylan-Brotherston
Bugzilla Link 52468
Version unspecified
OS Linux
CC @AaronBallman

Extended Description

Using the example given on the AST Matcher Reference for the Matcher

  void f(int b) {
    int a[b];
  }

running the example snippet will not produce the desired output

clang-query> m variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to(varDecl(hasName("b")))))))

Match #​1:

1 match.

The match occurs but no actual information is returned.

Using any of:

set output print
set output detailed-ast
set output dump

will give output.

But:

set output diag

the default,
will return it to no output.

This can be simplified to the most simple variableArrayType() expression with the same result (also on a bigger file)

clang-query> m variableArrayType()

Match #​1:


Match #​2:


Match #​3:


Match #​4:

4 matches.

This is of course in contrast to other matchers like varDecl() that will always output

clang-query> m varDecl()

Match #​1:

vla.c:1:8: note: "root" binds here
void f(int b) {
       ^~~~~

Match #​2:

vla.c:2:3: note: "root" binds here
  int a[b];
  ^~~~~~~~
2 matches.

Other matchers have a similar issue:

clang-query> m arrayType()

Match #​1:


Match #​2:

2 matches.

Apologies if this is documented behavior, but i haven't found it anywhere.

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