facebookarchive / pfff

Tools for code analysis, visualizations, or style-preserving source transformation.
http://github.com/facebook/pfff/wiki/Main
Other
2.44k stars 204 forks source link

sgrep on ternary operator in C/C++ #123

Open michaelmior opened 9 years ago

michaelmior commented 9 years ago

Consider the C and PHP source files below.

int foo = 1 ? 2 : 3;
<?php
$foo = 1 ? 2 : 3;
?>

sgrep -lang php -e 'X ? Y : Z' test.php will produce a result while sgrep -lang c -e 'X ? Y : Z' test.c does not. Any ideas why this would be happening? I'm not really familiar with OCaml, so I haven't dug into the source much.

michaelmior commented 9 years ago

Given the results of the dump below, I assume I could write some OCaml to match on CondExpr, but I'd like to avoid that if possible.

[Global(
   {v_name=("foo"); v_type=TBase(("int")); v_storage=DefaultStorage; 
    v_init=Some(CondExpr(Int(("1")), Int(("2")), Int(("3")))); })]
ghost commented 9 years ago

Thank you for reporting this issue and appreciate your patience. We've notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed.