[llvm-bugs] [Bug 42937] New: forEachArgumentWithParam AST matcher silently discards casts and parentheses
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Aug 8 12:38:12 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=42937
Bug ID: 42937
Summary: forEachArgumentWithParam AST matcher silently discards
casts and parentheses
Product: clang
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: dbeer1 at bloomberg.net
CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
richard-llvm at metafoo.co.uk
-- Overview --
The forEachArgumentWithParam AST matcher internally ignores casts and
parentheses before matching each argument. This behavior is not documented
anywhere, and makes the matcher unusable if those expressions need to be
captured.
The offending line of code is here, where ignoreParenCasts is called on the
argument before matching it:
https://github.com/llvm-mirror/clang/blob/release_90/include/clang/ASTMatchers/ASTMatchers.h#L3935
This behavior should at least be documented, but it would be nice if there was
a way to use the matcher without automatically skipping all casts.
-- How to replicate --
$ cat >test.cpp <<EOF
void foo(int);
void bar(int x)
{
foo(static_cast<int>(static_cast<short>(x)));
}
$ clang-query test.cpp
clang-query> m
callExpr(forEachArgumentWithParam(explicitCastExpr().bind("cast"), anything()))
-- Expected results --
The explicit cast expression in the first argument will be matched.
-- Actual results --
No matches found.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190808/7d60040e/attachment.html>
More information about the llvm-bugs
mailing list