[PATCH] D18073: Add memory allocating functions

Devin Coughlin via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 2 16:22:58 PDT 2016

dcoughlin added a comment.

In https://reviews.llvm.org/D18073#437171, @ariccio wrote:

> I should elaborate. The principle of operation of this latest patch is that the `FunctionDecl` in `IsCMemFunction` should never return a `nullptr` `IdentifierInfo*` from `getIdentifier` (is that a valid assumption?)

No. The identifier info will be null for C++ operators.

> Thus, when`! isWindowsMSVCEnvironment`, I leave the Windows-only memory allocating functions initialized to `nullptr`, which will never equal a non-null `IdentifierInfo*`, and never trigger on a non-Windows platform.

It is probably better to be explicit about this.

Comment at: llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:177
@@ -176,2 +176,3 @@
         II_if_nameindex(nullptr), II_if_freenameindex(nullptr),
-        II_wcsdup(nullptr), II_win_wcsdup(nullptr) {}
+        II_wcsdup(nullptr), II_wtempnam(nullptr), II_tempnam(nullptr),
+        II_win_wcsdup(nullptr), II_malloc_dbg(nullptr), II_free_dbg(nullptr),
Can you initialized these in the order the fields are declared? This will avoid warnings with '-Wreorder' enabled.

Comment at: llvm/tools/clang/test/Analysis/alternative-malloc-api.c:2
@@ +1,3 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.deadcode.UnreachableCode,alpha.core.CastSize,unix.Malloc,debug.ExprInspection -analyzer-store=region -verify %s
+#include "Inputs/system-header-simulator.h"
You should add a second RUN line here with the "-triple x86_64-windows -fms-compatibility" flags added to test analyzing with a windows target on all host platforms.


More information about the cfe-commits mailing list