Xazax-hun wrote:

I think the ideal solution would be something like using the 
[analyzer_noreturn](https://clang.llvm.org/docs/AttributeReference.html#analyzer-noreturn)
 attribute in GTest to mark branches that should not be taken by static 
analyzers because some invariants failed and every further diagnostics are 
false positive on that path. This is the solution that the Clang Static 
Analyzer recommends to users (adding annotations to custom asserts). That being 
said, there is a precedent of the analyzer recognizing custom assert functions 
and treating them as noreturn even if they are not annotated: 
https://github.com/llvm/llvm-project/blob/main/clang/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp

If GTest had a similar function for the assert failed paths, a similar approach 
could be taken for the dataflow framework as well. If there is no such function 
that we could match on in the expanded code, I don't think we could do 
anything, we might need to do changes to GTest.

All that being said, I think we want to provide a good experience for people 
using this popular testing library out of the box, even if they use an older 
version that does not have any annotations. I am OK with suppressing noisy 
static analysis results for test files for the time being. It looks like the 
current options are either leave it broken on tests or turn it off for tests as 
modeling non-test code is prioritized. As a users I would definitely prefer the 
latter. 

https://github.com/llvm/llvm-project/pull/115051
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to