llvm/llvm-project

hasAnyArgument() spuriously ignores match

Open

#75.754 geöffnet am 17. Dez. 2023

Auf GitHub ansehen
 (18 Kommentare) (0 Reaktionen) (1 zugewiesene Person)C++ (10.782 Forks)batch import
clang-queryclang:frontendconfirmedgood first issue

Repository-Metriken

Stars
 (26.378 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 1T 2h) (1.000 gemergte PRs in 30 T)

Beschreibung

hasAnyArgument() spuriously ignores a match with the program:

void foo (void *, void *);

struct S {
};

void f() {
   S s;
   foo(&s, &s);
}

and the query:

m callExpr(hasAnyArgument(hasType(asString("S *"))))
0 matches. 

However, the query:

m callExpr(hasArgument(0,hasType(asString("S *"))))

returns the expected result:

...clang_ast_bug_2.cpp:10:2: note: "root" binds here
 10 |         foo(&s, &s);
      |         ^~~~~~~~~~~
1 match.

I am using clang-query 17.0.2 built, I believe, by Mozilla.

Contributor Guide