summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem Dergachev <artem.dergachev@gmail.com>2018-02-08 23:28:29 +0000
committerArtem Dergachev <artem.dergachev@gmail.com>2018-02-08 23:28:29 +0000
commit9849f595b9f92914263f80cdb8c48ec78499ba0b (patch)
tree325a7a33e703cd968c9b747721754fdafc4cd2f1
parentbd275c7ba7e50861202219c793f650becd72f48f (diff)
downloadbcm5719-llvm-9849f595b9f92914263f80cdb8c48ec78499ba0b.tar.gz
bcm5719-llvm-9849f595b9f92914263f80cdb8c48ec78499ba0b.zip
[analyzer] MallocChecker: Fix one more bug category.
Even though most of the inconsistencies in MallocChecker's bug categories were fixed in r302016, one more was introduced in r301913 which was later missed. Patch by Henry Wong! Differential Revision: https://reviews.llvm.org/D43074 llvm-svn: 324680
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp4
-rw-r--r--clang/test/Analysis/malloc-fnptr-plist.c11
2 files changed, 13 insertions, 2 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
index a1a540c4b96..378728dc613 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -2075,8 +2075,8 @@ void MallocChecker::ReportFunctionPointerFree(CheckerContext &C, SVal ArgVal,
if (ExplodedNode *N = C.generateErrorNode()) {
if (!BT_BadFree[*CheckKind])
- BT_BadFree[*CheckKind].reset(
- new BugType(CheckNames[*CheckKind], "Bad free", "Memory Error"));
+ BT_BadFree[*CheckKind].reset(new BugType(
+ CheckNames[*CheckKind], "Bad free", categories::MemoryError));
SmallString<100> Buf;
llvm::raw_svector_ostream Os(Buf);
diff --git a/clang/test/Analysis/malloc-fnptr-plist.c b/clang/test/Analysis/malloc-fnptr-plist.c
new file mode 100644
index 00000000000..6490eeb1cc0
--- /dev/null
+++ b/clang/test/Analysis/malloc-fnptr-plist.c
@@ -0,0 +1,11 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker core,unix.Malloc -analyzer-output=plist -o %t.plist -verify %s
+// RUN: FileCheck --input-file=%t.plist %s
+
+void free(void *);
+void (*fnptr)(int);
+void foo() {
+ free((void *)fnptr); // expected-warning{{Argument to free() is a function pointer}}
+}
+
+// Make sure the bug category is correct.
+// CHECK: <key>category</key><string>Memory error</string>
OpenPOWER on IntegriCloud