R
R
ramntry2012-11-12 12:37:11
Programming
ramntry, 2012-11-12 12:37:11

Clang as a static analysis tool: only processing specified files?

A tool for static analysis of C++ code is being developed. The main work is done by means of Clang. The following problem has arisen: I can't figure out how to make Clang (and our user code) issue warnings and other information only about code written by the end user, and not library code. At the same time, it is clear that you cannot simply ignore include's - then you will not parse the code using the names declared in the corresponding headers.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Ramires, 2012-11-12
@Ramires

I think you have already looked at these links, but suddenly...
Article on Clang API
Plugin for SublimeText2 , parsed with Clang. Written in python.
I couldn't remember anything else.

F
FlexFerrum, 2012-11-12
@FlexFerrum

It all depends on what mechanism is used to receive diagnostics from clang and issue this diagnostic to the user. If this is done on the basis of your own DiagnosticRenderer, then each message is associated with the place in the source text for which it was issued. Compare the name of the file for which the message was issued with the name of the file being processed - and voila, if the file is not the current one, do not display anything.
If the clang-c API is used, then you can use the clang_getDiagnosticSetFromTU method , and then filter everything in the same way - by the name of the file for which this or that message was issued.

F
FlexFerrum, 2012-11-12
@FlexFerrum

And another link that might be helpful. This is a clang-based C++ code parser for Qt Creator:
https://qt.gitorious.org/qt-creator/qt-creator/trees/wip/clang/src/plugins/clangcodemodel

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question