Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can clang be told not to analyze certain files?

Tags:

I'm trying to use clang to profile a project I'm working on. The project includes a rather large static library that is included in Xcode as a dependency.

I would really like clang to not analyze the dependencies' files, as it seems to make clang fail. Is this possible? I've been reading the clang documentation, and I haven't found it.

like image 962
John Biesnecker Avatar asked May 13 '09 09:05

John Biesnecker


People also ask

Is clang tidy a static analysis tool?

clang-tidy is a clang-based C++ “linter” tool. Its purpose is to provide an extensible framework for diagnosing and fixing typical programming errors, like style violations, interface misuse, or bugs that can be deduced via static analysis.

What is Clang static analyzer?

The Clang Static Analyzer is a source code analysis tool that finds bugs in C, C++, and Objective-C programs. It implements path-sensitive, inter-procedural analysis based on symbolic execution technique.


2 Answers

As a last resort, there is a brute force option.

Add this to the beginning of a file:

// Omit from static analysis. #ifndef __clang_analyzer__ 

Add this to the end:

#endif // not __clang_analyzer__ 

and clang --analyze won't see the contents of the file.

reference: Controlling Static Analyzer Diagnostics

like image 197
otto Avatar answered Oct 18 '22 10:10

otto


So, this isn't really an answer, but it worked well enough.

What I ended up doing was building the static library ahead of time, and then building the project using scan-build. Since there was already an up-to-date build of the static library, it wasn't rebuilt and thus wasn't scanned.

I'd still love to have a real answer for this, though.

like image 44
John Biesnecker Avatar answered Oct 18 '22 10:10

John Biesnecker