summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/cstring-syntax-weird2.c
diff options
context:
space:
mode:
authorArtem Dergachev <artem.dergachev@gmail.com>2019-08-28 18:44:38 +0000
committerArtem Dergachev <artem.dergachev@gmail.com>2019-08-28 18:44:38 +0000
commit630f7daf80fe36d3aa4a9ebe60e7abefae514bba (patch)
tree476edc9fbf1518b032ec8188114f17e501780205 /clang/test/Analysis/cstring-syntax-weird2.c
parent0909a392f318872a1eacbdc9a6044cb437095a11 (diff)
downloadbcm5719-llvm-630f7daf80fe36d3aa4a9ebe60e7abefae514bba.tar.gz
bcm5719-llvm-630f7daf80fe36d3aa4a9ebe60e7abefae514bba.zip
[analyzer] Fix analyzer warnings on analyzer.
Write tests for the actual crash that was found. Write comments and refactor code around 17 style bugs and suppress 3 false positives. Differential Revision: https://reviews.llvm.org/D66847 llvm-svn: 370246
Diffstat (limited to 'clang/test/Analysis/cstring-syntax-weird2.c')
-rw-r--r--clang/test/Analysis/cstring-syntax-weird2.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/test/Analysis/cstring-syntax-weird2.c b/clang/test/Analysis/cstring-syntax-weird2.c
new file mode 100644
index 00000000000..a0f28536d4a
--- /dev/null
+++ b/clang/test/Analysis/cstring-syntax-weird2.c
@@ -0,0 +1,17 @@
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=unix.cstring.BadSizeArg \
+// RUN: -verify %s
+
+// expected-no-diagnostics
+
+typedef __SIZE_TYPE__ size_t;
+// The last parameter is normally size_t but the test is about the abnormal
+// situation when it's not a size_t.
+size_t strlcpy(char *, const char *, void (*)());
+
+void foo();
+
+void testWeirdDecls(const char *src) {
+ char dst[10];
+ strlcpy(dst, src, foo); // no-crash
+ strlcpy(dst, src, &foo); // no-crash
+}
OpenPOWER on IntegriCloud