diff options
| author | Artem Dergachev <artem.dergachev@gmail.com> | 2018-07-30 23:44:37 +0000 |
|---|---|---|
| committer | Artem Dergachev <artem.dergachev@gmail.com> | 2018-07-30 23:44:37 +0000 |
| commit | 67fdf81f0c98d7389057a6030124b59f95280125 (patch) | |
| tree | c610635e45dc9ed52e2abdd8ae6492f28417017c /clang/test/Analysis/cstring-ranges.c | |
| parent | 934864bfa79f23b2a230f0847b0649899aa82d2a (diff) | |
| download | bcm5719-llvm-67fdf81f0c98d7389057a6030124b59f95280125.tar.gz bcm5719-llvm-67fdf81f0c98d7389057a6030124b59f95280125.zip | |
[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
Diffstat (limited to 'clang/test/Analysis/cstring-ranges.c')
| -rw-r--r-- | clang/test/Analysis/cstring-ranges.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/test/Analysis/cstring-ranges.c b/clang/test/Analysis/cstring-ranges.c new file mode 100644 index 00000000000..4fcd7eaa8be --- /dev/null +++ b/clang/test/Analysis/cstring-ranges.c @@ -0,0 +1,15 @@ +// 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: ^ ~ |

