From df539194a00bd026cdc0da67438ad443c4f2d310 Mon Sep 17 00:00:00 2001 From: Anna Zaks Date: Fri, 1 Mar 2013 06:38:16 +0000 Subject: [PATCH] [analyzer] Reword FAQ Reword the FAQ to stress more that the assert should be used only in case the developer is sure that the issue is a false positive. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176335 91177308-0d34-0410-b5e6-96231b3b80d8 --- www/analyzer/faq.html | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/www/analyzer/faq.html b/www/analyzer/faq.html index 5c132b57f2..129bfb63bb 100644 --- a/www/analyzer/faq.html +++ b/www/analyzer/faq.html @@ -68,13 +68,15 @@ int foo(int *b) { example use assert -

You can teach the analyzer facts about your code as well as document it by -using assertions. In the contrived example above, the analyzer reports an error -on the path which assumes that the loop is never entered. However, the owner of -the code might know that the loop is always entered because the input parameter -length is always greater than 0. The false positive can be -suppressed by asserting this knowledge, adding assert(length > 0) in -the beginning of the function.

+

In the contrived example above, the analyzer has detected that the body of +the loop is never entered for the case where length <= 0. In this +particular example, you may know that the loop will always be entered because +the input parameter length will be greater than zero in all calls to this +function. You can teach the analyzer facts about your code as well as document +it by using assertions. By adding assert(length > 0) in the beginning +of the function, you tell the analyzer that your code is never expecting a zero +or a negative value, so it won't need to test the correctness of those paths. +

 int foo(int length) {
-- 
2.40.0