--- layout: fc_discuss_archives title: Message 9 from Frama-C-discuss on May 2017 ---
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Frama-c-discuss] Support LLVM database "compile_commands.json"



Hello,

2017-05-05 17:39 GMT+02:00 Matt <mattator at gmail.com>:
> Hi,
>
> I am fairly new to frama-c. I followed the great tutorial on the eva
> plugin and I am now trying to run frama-c on the neovim project
> (https://github.com/neovim/neovim/wiki/Building-Neovim) to get some
> metrics such as cyclomatic complexity.

Syntactic metrics are not exactly the main target of Frama-C. Are you
planning to use EVA (which looks like a major endeavor on neovim)
afterwards? Otherwise, I'm not completely sure this is worth the
effort.

> I wonder if it's possible to pass several -cpp-command depending on
> the file  "-cpp-command file1.c -cpp-command file2.c etc" to match the
> flags in the compilation database (made popular with clang, can be
> generated by cmake/bear and is used in tools such as
> chromatica.nvim/YouCompleteMe etc):
> https://transfer.sh/EcL5c/compile_commands.json

No. support for pre-processing in Frama-C is quite basic. That said,
it is possible to do something like
frama-c -ocode file1.i -cpp-command cmd1 -print file1.c -then -ocode
file2.i -cpp-command cmd2 -print file2.c [...] -then -ocode="" file1.i
file2.i [analysis options]

or of course
frama-c -ocode file1.i -cpp-command cmd1 -print file1.c
frama-c -ocode file2.i -cpp-command cmd2 -print file2.c
...
frama-c file1.i file2.i ...

As an aside, unless you really want to change the whole pre-processor,
it's usually better to use -cpp-extra-args="-Iinclude-lib -DFOO ..."
rather than -cpp-command.

Best regards,
-- 
E tutto per oggi, a la prossima volta
Virgile