llvm-capstone/clang/test/Analysis/cstring-ranges.c
Artem Dergachev 67fdf81f0c [analyzer] CStringChecker: Remember to highlight the argument expression range.
When emitting a bug report, it is important to highlight which argument of the
call-expression is causing the problem.

Before:
warning: Null pointer argument in call to string comparison function
  strcmp(a, b);
  ^~~~~~~~~~~~

After:
warning: Null pointer argument in call to string comparison function
  strcmp(a, b);
  ^      ~

Affects other output modes as well, not just text.

Differential Revision: https://reviews.llvm.org/D50028

llvm-svn: 338333
2018-07-30 23:44:37 +00:00

16 lines
440 B
C

// RUN: %clang_analyze_cc1 -analyzer-checker=unix.cstring -analyzer-output=text %s 2>&1 | FileCheck %s
// This test verifies argument source range highlighting.
// Otherwise we've no idea which of the arguments is null.
char *strcpy(char *, const char *);
void foo() {
char *a = 0, *b = 0;
strcpy(a, b);
}
// CHECK: warning: Null pointer argument in call to string copy function
// CHECK-NEXT: strcpy(a, b);
// CHECK-NEXT: ^ ~