[llvm-bugs] [Bug 39358] New: The core.NonNullParamChecker message is missing important information

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Oct 19 11:45:49 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=39358

            Bug ID: 39358
           Summary: The core.NonNullParamChecker message is missing
                    important information
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Static Analyzer
          Assignee: noqnoqneo at gmail.com
          Reporter: alexfh at google.com
                CC: llvm-bugs at lists.llvm.org

The core.NonNullParamChecker checker warnings now read "Null pointer passed as
an argument to a 'nonnull' parameter". In the presence of long paths, macros,
etc. the message becomes difficult to understand. It could benefit from some
disambiguating information (which parameter? what's the function name?).

I tried to produce an isolated test case similar to what I've seen in real
code, but it doesn't let one fully experience the frustration I had trying to
investigate a real case.

$ cat q.cc
#include <cstring>
#define Q(a, b, c, d, e) memcmp(a, b, e) || memcmp(c, d, e)
void f() {
  char *a = nullptr;
  char *b = nullptr;
  char c[10];
  char d[10];
  if (Q(a, b, c, d, 10)) {
  }
}
$ clang_tidy -checks=-*,clang-analyzer* q.cc --
1 warning generated.
q.cc:8:7: warning: Null pointer passed as an argument to a 'nonnull' parameter
[clang-analyzer-core.NonNullParamChecker]
  if (Q(a, b, c, d, 10)) {
      ^
q.cc:2:26: note: expanded from macro 'Q'
#define Q(a, b, c, d, e) memcmp(a, b, e) || memcmp(c, d, e)
                         ^
q.cc:4:3: note: 'a' initialized to a null pointer value
  char *a = nullptr;
  ^
q.cc:8:7: note: Null pointer passed as an argument to a 'nonnull' parameter
  if (Q(a, b, c, d, 10)) {
      ^
q.cc:2:26: note: expanded from macro 'Q'
#define Q(a, b, c, d, e) memcmp(a, b, e) || memcmp(c, d, e)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181019/d36f24b6/attachment.html>


More information about the llvm-bugs mailing list