[PATCH] D23112: [analyzer] Correctly add assumptions based on array bounds.

Artem Dergachev via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 3 07:20:05 PDT 2016

NoQ added a comment.

Nice catch!

Now, this needs a test. How about this one:

  // enable the debug.ExprInspection checker?
  void clang_analyzer_eval(int);
  void test_asume_after_access(unsigned long x) {
    char buf[100];
    buf[x] = 1;
    clang_analyzer_eval(x <= 99); // expected-warning{{TRUE}}

By the way, if we replace `char` with `int`, this test fails even with your patch. The reason is, the assumption is added on `(4 * x)` rather than on `x`, and the constraint manager explodes. Does anybody volunteer to fix this (eg. on the checker side - throw easier equations at the solver)?


More information about the cfe-commits mailing list