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: unassignedclangb...@nondot.org
          Reporter: dbe...@bloomberg.net
                CC: llvm-bugs@lists.llvm.org, neeil...@live.com,
                    richard-l...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to