[PATCH] D12725: [analyzer] A fix for substraction of an integer from a pointer.

Anna Zaks via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 9 15:34:52 PDT 2015


zaks.anna added a comment.

Let's make the test more explicit about what is being tested; for example,
void negativeIndex(char *str) {

  char *ptr = str + 1;
  *ptr = 'a';
  clang_analyzer_eval(*ptr == 'a'); // expected-warning{{TRUE}}
  ptr = str - 1;
  clang_analyzer_eval(*ptr == 'a'); // expected-warning{{UNKNOWN}}
  clang_analyzer_eval(*(str + 1) == 'a'); // expected-warning{{TRUE}}
  ptr = str;
  ptr -= 1;
  clang_analyzer_eval(*ptr == 'a'); // expected-warning{{UNKNOWN}}
  ptr = str;
  --ptr;
  clang_analyzer_eval(*ptr == 'a'); // expected-warning{{UNKNOWN}}

}

Otherwise, LGTM


http://reviews.llvm.org/D12725





More information about the cfe-commits mailing list