Can clang be told not to analyze certain files?

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.


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