[cfe-dev] How to use libtooling to parse multiple files at once? and succesfully find stddef.h?
rayjcwu
rayjcwu at gmail.com
Mon Oct 28 22:46:46 PDT 2013
I'm writing a tool to parse C family source code basically follow these
tutorials
[1] http://clang.llvm.org/docs/LibTooling.html#libtooling-builtin-includes
[2]
http://kevinaboos.blogspot.com/2013/07/clang-tutorial-part-ii-libtooling.html
I try to parse opencv <https://github.com/Itseez/opencv> for now since it
uses CMake allowing me to get a correct compile_commands.json for free.
My first problme is how do I specify to parse thousands of files at once? At
first I thought giving libtooling the path of compile_commands.json then it
will do the rest. However, if I use run "$ mybinary -p . -- " and use
CommonOptionsParser to process argc, argv, it will complain "Not enough
positional command line arguments specified!", so I still have to specified
all files I want to parse.
If I use CompilationDatabase::autoDetectFromDirectory to load
compile_commands.json and use getAllFiles() to pass to ClangTool to parse
all files, it could parse but it can't find headers like stdarg.h, stddef.h
and such. In FAQ <http://clang.llvm.org/docs/FAQ.html> it said use clang
with -### option will see all options necessary for this issue.
However, since I'm using CompilationDatabase::autoDetectFromDirectory to
start parsing, where should these options go? If I pass these options to
CommonOptionsParser, how to do I start parsing (since it always complains
about missing positional arguments). Besides, I want my tool only need to
pass the path containing compile_commands.json as argument, how could my
program get options from "clang -### -c _file_to_compile_"?
--
View this message in context: http://clang-developers.42468.n3.nabble.com/How-to-use-libtooling-to-parse-multiple-files-at-once-and-succesfully-find-stddef-h-tp4035389.html
Sent from the Clang Developers mailing list archive at Nabble.com.
More information about the cfe-dev
mailing list