xref: /llvm-project/clang/test/Analysis/cstring-ranges.c (revision 0dd49a5628bbe01cecf6516017da59ae44863ab3)
1 // RUN: %clang_analyze_cc1 -analyzer-checker=unix.cstring -analyzer-output=text %s 2>&1 | FileCheck %s
2 
3 // This test verifies argument source range highlighting.
4 // Otherwise we've no idea which of the arguments is null.
5 // These days we actually also have it in the message,
6 // but the range is still great to have.
7 
8 char *strcpy(char *, const char *);
9 
foo(void)10 void foo(void) {
11   char *a = 0, *b = 0;
12   strcpy(a, b);
13 }
14 
15 // CHECK: warning: Null pointer passed as 1st argument to string copy function
16 // CHECK-NEXT: strcpy(a, b);
17 // CHECK-NEXT: ^      ~
18