From: Artem Dergachev Date: Thu, 8 Feb 2018 23:28:29 +0000 (+0000) Subject: [analyzer] MallocChecker: Fix one more bug category. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b881e2ba8cc1a00d1c01adb20e585488304fde5f;p=clang [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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@324680 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/lib/StaticAnalyzer/Checkers/MallocChecker.cpp index a1a540c4b9..378728dc61 100644 --- a/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ b/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/test/Analysis/malloc-fnptr-plist.c b/test/Analysis/malloc-fnptr-plist.c new file mode 100644 index 0000000000..6490eeb1cc --- /dev/null +++ b/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: categoryMemory error