ilya-palachev added a comment.

Thanks for review!

> As Artem points out, the checkers in tree do not create a node for every bug 
> reported - there is no reason to do that.

Yes... But why does `generateNonFatalErrorNode` return `nullptr` in case when 
the node already exists? Isn't it designed so that to prevent multiple reports 
being thrown for the same node? If so, then the code contains a lot of such 
checks.

I don't understand why the following test passes, because each of two checkers: 
`MallocChecker` and `SimpleStreamChecker` are using `generateNonFatalErrorNode` 
method:

  // RUN: %clang_cc1 -analyze 
-analyzer-checker=unix.Malloc,alpha.unix.SimpleStream -analyzer-store region 
-verify %s
  
  typedef struct _IO_FILE FILE;
  extern FILE *fopen(const char *path, const char *mode);
  extern int fclose(FILE *fp);
  
  typedef __typeof(sizeof(int)) size_t;
  void *malloc(size_t);
  void free(void *);
  
  void test() {
    void *p = malloc(1);
    void *r = fopen("foo", "r");
    if (r) {
      (void)(p - r);
      // expected-warning@-1{{Potential leak of memory}}
      // expected-warning@-2{{Opened file is never closed}}
    }
    else {
      fclose(r);
      free(p);
    }
  }

Maybe it's possible to invent such a testcase when two checkers begin to 
conflict for the node. Or not?


Repository:
  rL LLVM

https://reviews.llvm.org/D27710



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to