mire787 / google-glog

Automatically exported from code.google.com/p/google-glog
Other
0 stars 0 forks source link

FATAL and CHECK aren't handled by Clang analyzer #192

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
The clang static analyzer doesn't currently support the 'noreturn' attribute on 
the LogMessageFatal destructor.

This means that code like:
void Foo(Bar* b) {
  CHECK(b != NULL);
  b->blah();
}

will trigger an analyzer message saying that the CHECK "false" branch was 
taken, and then "b->" was a NULL dereference.

See http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-March/035689.html for some 
discussion about fixing this on the analyzer side.

I found I was also able to fix this in glog by adding the "analyzer_noreturn" 
attribute on the LogMessageFatal *constructor*. This isn't quite accurate in 
that the constructor does return, but it short circuits those branches out of 
the analysis path and removed a bunch of false positives in my project.

Original issue reported on code.google.com by tlip...@gmail.com on 27 Mar 2014 at 1:08