From: Anna Zaks Date: Tue, 27 Oct 2015 20:19:38 +0000 (+0000) Subject: [analyzer] Enhance FAQ with instructions on handing unused variables. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=87b874990941392ad35ed2254357e4d9185bf15b;p=clang [analyzer] Enhance FAQ with instructions on handing unused variables. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@251448 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/www/analyzer/faq.html b/www/analyzer/faq.html index 129bfb63bb..9d2962b112 100644 --- a/www/analyzer/faq.html +++ b/www/analyzer/faq.html @@ -26,6 +26,8 @@ the bug is reached?
  • The analyzer reports a null dereference, but I know that the pointer is never null. How can I tell the analyzer that a pointer can never be null?
  • +
  • How do I tell the static analyzer that I don't care about a specific dead store?
  • +
  • How do I tell the static analyzer that I don't care about a specific unused instance variable in Objective C?
  • The analyzer assumes that a loop body is never entered. How can I tell it that the loop body will be entered at least once?
  • How can I suppress a specific analyzer warning?
  • How can I selectively exclude code the analyzer examines?
  • @@ -64,6 +66,18 @@ int foo(int *b) { return *b; } +

    Q: How do I tell the static analyzer that I don't care about a specific dead store?

    + +

    When the analyzer sees that a value stored into a variable is never used, it's going to produce a message similar to this one: +

    Value stored to 'x' is never read
    +You can use the (void)x; idiom to acknowledge that there is a dead store in your code but you do not want it to be reported in the future.

    + +

    Q: How do I tell the static analyzer that I don't care about a specific unused instance variable in Objective C?

    + +

    When the analyzer sees that a value stored into a variable is never used, it is going to produce a message similar to this one: +

    Instance variable 'commonName' in class 'HappyBird' is never used by the methods in its @implementation
    +You can add __attribute__((unused)) to the instance variable declaration to suppress the warning.

    +

    Q: The analyzer assumes that a loop body is never entered. How can I tell it that the loop body will be entered at least once?

    example use assert