Exclude protobuf generated files

Hello all,
Recently, we started using the clang static analyzer in our project
and it's already very helpful. One thing we'd like to improve though
is to reduce the number of the warnings/bugs we get about protobuf
generated files -*.pb.cc- (we're not really interested in them). What
would be the best way to avoid analysing them without affecting
heavily the rest of the code? E.g. would it be better to avoid
generating these files completely or it'd be better to wrap each of
these files in #ifndef __clang_analyzer__/#endif blocks?

Thank you,
George

Hi George,

I think the mitigation strategy for reducing false positives right now from the analyzer are the two techniques you mention.

You can use __clang_analyzer__ but it really is a heavy hammer, and essentially precludes the analyzer from doing anything useful with those files. If you are using the analyzer from within Xcode, you also need to make sure that the source can still parse (during analysis) after you add the __clang_analyzer__ guards or Xcode will abort the analysis of your project because it encountered source files that can't parse.

Specifically with respect to protocol buffer code, could you file one or more PRs about representative issues you are seeing? There's a possibility they could be pruned using heuristics within the analyzer. If protocol buffer code tends to be generated idiomatically with specific file extensions, e.g. .pb.cc, we could possibly use even that to tune some heuristics on the analyzer to avoid false positives.

Cheers,
Ted

/subscribe - I’m very interested in false positives in protocol buffer code :slight_smile:

No need for "if". protoc is documented to produce x.pb.cc and x.pb.h
from x.proto (https://developers.google.com/protocol-buffers/docs/reference/cpp-generated#invocation)

Csaba

Hi Ted,
Sure, glad to help. Where should i file these PRs? To Bugzilla?

Thanks,
George

Yes please, Bugzilla is the place to file these. Feel free to file one or more, but regardless of quantity context and explanation of what you are seeing is usually invaluable for these kind of issues. If you file any PRs, please respond to the thread and post the links to them here.

Cheers,
Ted