Search for function/variable usage
pfirsich opened this issue · comments
I do most of my "code exploration" with ag and I always wished something like this would exist, so thanks for doing it! And I think searching for declarations is quite cool already, but it's usually not very hard to do without an AST. It is much harder to search for usage of functions and variables though. Would it be possible to add this to fccf?
Thanks for the request. I've tried to add support for this now.
You can use the flag --ie
or --include-expressions
to get all the places where a variable or function was used.
Example 1: Usage of function
Look for all the places where the function isdigit
was called:
Example 2: Usage of variable
Hope this meets your needs.
This is exactly what I was looking for, thank you!
Sadly it's not quite working right in my test project. I am currently working on an HTTP server and if run fccf --ie debug src
in the repository root, I would expect to see usages of the slog::debug
(defined in src/log.hpp), but I don't see any, even though there a plenty of them (see e.g. src/main.cpp or src/ssl.cpp). I suspected it might be because it's a variadic template function, but that doesn't seem to be a problem in a minimal test.
What version of fccf
are you using? Is it the latest v0.5.0
?
This is my output:
2022-04-29.06-42-19.mp4
NOTE: Run with --verbose
flag to check if there are include errors reported by libclang
. I mention this here in the README.
If you see that certain headers cannot be found, you can use --include-dir
or -I
to provide additional include directories and resolve these errors.
2022-04-29.06-43-28.mp4
I pulled the night before posting my comment, my bad! The current version works great. Thanks again!