Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-03-07 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL262894: [analyzer] Fix missed leak from MSVC specific 
allocation functions (authored by zaks).

Changed prior to commit:
  http://reviews.llvm.org/D17688?vs=49845=50013#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17688

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  cfe/trunk/test/Analysis/malloc.c

Index: cfe/trunk/test/Analysis/malloc.c
===
--- cfe/trunk/test/Analysis/malloc.c
+++ cfe/trunk/test/Analysis/malloc.c
@@ -4,6 +4,21 @@
 
 void clang_analyzer_eval(int);
 
+// Without -fms-compatibility, wchar_t isn't a builtin type. MSVC defines
+// _WCHAR_T_DEFINED if wchar_t is available. Microsoft recommends that you use
+// the builtin type: "Using the typedef version can cause portability
+// problems", but we're ok here because we're not actually running anything.
+// Also of note is this cryptic warning: "The wchar_t type is not supported
+// when you compile C code".
+//
+// See the docs for more:
+// https://msdn.microsoft.com/en-us/library/dh8che7s.aspx
+#if !defined(_WCHAR_T_DEFINED)
+// "Microsoft implements wchar_t as a two-byte unsigned value"
+typedef unsigned short wchar_t;
+#define _WCHAR_T_DEFINED
+#endif // !defined(_WCHAR_T_DEFINED)
+
 typedef __typeof(sizeof(int)) size_t;
 void *malloc(size_t);
 void *alloca(size_t);
@@ -13,9 +28,15 @@
 void *reallocf(void *ptr, size_t size);
 void *calloc(size_t nmemb, size_t size);
 char *strdup(const char *s);
+wchar_t *wcsdup(const wchar_t *s);
 char *strndup(const char *s, size_t n);
 int memcmp(const void *s1, const void *s2, size_t n);
 
+// Windows variants
+char *_strdup(const char *strSource);
+wchar_t *_wcsdup(const wchar_t *strSource);
+void *_alloca(size_t size);
+
 void myfoo(int *p);
 void myfooint(int p);
 char *fooRetPtr();
@@ -55,6 +76,10 @@
   int *p = alloca(sizeof(int));
 } // no warn
 
+void winAllocaTest() {
+  int *p = _alloca(sizeof(int));
+} // no warn
+
 void allocaBuiltinTest() {
   int *p = __builtin_alloca(sizeof(int));
 } // no warn
@@ -210,6 +235,11 @@
   int *p = alloca(0); // no warning
 }
 
+void CheckUseZeroWinAllocatedNoWarn2() {
+  int *p = _alloca(0); // no warning
+}
+
+
 void CheckUseZeroAllocatedNoWarn3() {
   int *p = malloc(0);
   int *q = realloc(p, 8); // no warning
@@ -233,6 +263,11 @@
   return *p; // expected-warning {{Use of zero-allocated memory}}
 }
 
+char CheckUseZeroWinAllocated2() {
+  char *p = _alloca(0);
+  return *p; // expected-warning {{Use of zero-allocated memory}}
+}
+
 void UseZeroAllocated(int *p) {
   if (p)
 *p = 7; // expected-warning {{Use of zero-allocated memory}}
@@ -1076,6 +,21 @@
   s2[validIndex + 1] = 'b';
 } // expected-warning {{Potential leak of memory pointed to by}}
 
+void testWinStrdup(const char *s, unsigned validIndex) {
+  char *s2 = _strdup(s);
+  s2[validIndex + 1] = 'b';
+} // expected-warning {{Potential leak of memory pointed to by}}
+
+void testWcsdup(const wchar_t *s, unsigned validIndex) {
+  wchar_t *s2 = wcsdup(s);
+  s2[validIndex + 1] = 'b';
+} // expected-warning {{Potential leak of memory pointed to by}}
+
+void testWinWcsdup(const wchar_t *s, unsigned validIndex) {
+  wchar_t *s2 = _wcsdup(s);
+  s2[validIndex + 1] = 'b';
+} // expected-warning {{Potential leak of memory pointed to by}}
+
 int testStrndup(const char *s, unsigned validIndex, unsigned size) {
   char *s2 = strndup(s, size);
   s2 [validIndex + 1] = 'b';
@@ -1091,6 +1141,24 @@
   free(s2);
 }
 
+void testWinStrdupContentIsDefined(const char *s, unsigned validIndex) {
+  char *s2 = _strdup(s);
+  char result = s2[1];// no warning
+  free(s2);
+}
+
+void testWcsdupContentIsDefined(const wchar_t *s, unsigned validIndex) {
+  wchar_t *s2 = wcsdup(s);
+  wchar_t result = s2[1];// no warning
+  free(s2);
+}
+
+void testWinWcsdupContentIsDefined(const wchar_t *s, unsigned validIndex) {
+  wchar_t *s2 = _wcsdup(s);
+  wchar_t result = s2[1];// no warning
+  free(s2);
+}
+
 // 
 // Test the system library functions to which the pointer can escape.
 // This tests false positive suppression.
@@ -1444,6 +1512,14 @@
   return strdup(strdup(str)); // expected-warning{{leak}}
 }
 
+char *testWinLeakWithinReturn(char *str) {
+  return _strdup(_strdup(str)); // expected-warning{{leak}}
+}
+
+wchar_t *testWinWideLeakWithinReturn(wchar_t *str) {
+  return _wcsdup(_wcsdup(str)); // expected-warning{{leak}}
+}
+
 void passConstPtr(const char * ptr);
 
 void testPassConstPointer() {
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -169,11 +169,12 @@
 {
 public:
   MallocChecker()
-  : II_alloca(nullptr), II_malloc(nullptr), II_free(nullptr),

Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-03-05 Thread Alexander Riccio via cfe-commits
ariccio added a comment.

In http://reviews.llvm.org/D17688#366780, @zaks.anna wrote:

> LGTM. Thanks!
>
> I can commit this in your behalf.


Oh, and yeah, I don't have privs.


http://reviews.llvm.org/D17688



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-03-04 Thread Alexander Riccio via cfe-commits
ariccio added a comment.

In http://reviews.llvm.org/D17688#368330, @zaks.anna wrote:

>


?


http://reviews.llvm.org/D17688



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-03-04 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.




http://reviews.llvm.org/D17688



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-03-04 Thread Alexander Riccio via cfe-commits
ariccio updated this revision to Diff 49845.
ariccio added a comment.

Alrighty. This final version of the patch causes no test failures (vs the 
unmodified build*).

*An unrelated test normally fails on my machine.


http://reviews.llvm.org/D17688

Files:
  llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  llvm/tools/clang/test/Analysis/malloc.c

Index: llvm/tools/clang/test/Analysis/malloc.c
===
--- llvm/tools/clang/test/Analysis/malloc.c
+++ llvm/tools/clang/test/Analysis/malloc.c
@@ -4,6 +4,21 @@
 
 void clang_analyzer_eval(int);
 
+// Without -fms-compatibility, wchar_t isn't a builtin type. MSVC defines
+// _WCHAR_T_DEFINED if wchar_t is available. Microsoft recommends that you use
+// the builtin type: "Using the typedef version can cause portability
+// problems", but we're ok here because we're not actually running anything.
+// Also of note is this cryptic warning: "The wchar_t type is not supported
+// when you compile C code".
+//
+// See the docs for more:
+// https://msdn.microsoft.com/en-us/library/dh8che7s.aspx
+#if !defined(_WCHAR_T_DEFINED)
+// "Microsoft implements wchar_t as a two-byte unsigned value"
+typedef unsigned short wchar_t;
+#define _WCHAR_T_DEFINED
+#endif // !defined(_WCHAR_T_DEFINED)
+
 typedef __typeof(sizeof(int)) size_t;
 void *malloc(size_t);
 void *alloca(size_t);
@@ -13,9 +28,15 @@
 void *reallocf(void *ptr, size_t size);
 void *calloc(size_t nmemb, size_t size);
 char *strdup(const char *s);
+wchar_t *wcsdup(const wchar_t *s);
 char *strndup(const char *s, size_t n);
 int memcmp(const void *s1, const void *s2, size_t n);
 
+// Windows variants
+char *_strdup(const char *strSource);
+wchar_t *_wcsdup(const wchar_t *strSource);
+void *_alloca(size_t size);
+
 void myfoo(int *p);
 void myfooint(int p);
 char *fooRetPtr();
@@ -55,6 +76,10 @@
   int *p = alloca(sizeof(int));
 } // no warn
 
+void winAllocaTest() {
+  int *p = _alloca(sizeof(int));
+} // no warn
+
 void allocaBuiltinTest() {
   int *p = __builtin_alloca(sizeof(int));
 } // no warn
@@ -210,6 +235,11 @@
   int *p = alloca(0); // no warning
 }
 
+void CheckUseZeroWinAllocatedNoWarn2() {
+  int *p = _alloca(0); // no warning
+}
+
+
 void CheckUseZeroAllocatedNoWarn3() {
   int *p = malloc(0);
   int *q = realloc(p, 8); // no warning
@@ -233,6 +263,11 @@
   return *p; // expected-warning {{Use of zero-allocated memory}}
 }
 
+char CheckUseZeroWinAllocated2() {
+  char *p = _alloca(0);
+  return *p; // expected-warning {{Use of zero-allocated memory}}
+}
+
 void UseZeroAllocated(int *p) {
   if (p)
 *p = 7; // expected-warning {{Use of zero-allocated memory}}
@@ -1076,6 +,21 @@
   s2[validIndex + 1] = 'b';
 } // expected-warning {{Potential leak of memory pointed to by}}
 
+void testWinStrdup(const char *s, unsigned validIndex) {
+  char *s2 = _strdup(s);
+  s2[validIndex + 1] = 'b';
+} // expected-warning {{Potential leak of memory pointed to by}}
+
+void testWcsdup(const wchar_t *s, unsigned validIndex) {
+  wchar_t *s2 = wcsdup(s);
+  s2[validIndex + 1] = 'b';
+} // expected-warning {{Potential leak of memory pointed to by}}
+
+void testWinWcsdup(const wchar_t *s, unsigned validIndex) {
+  wchar_t *s2 = _wcsdup(s);
+  s2[validIndex + 1] = 'b';
+} // expected-warning {{Potential leak of memory pointed to by}}
+
 int testStrndup(const char *s, unsigned validIndex, unsigned size) {
   char *s2 = strndup(s, size);
   s2 [validIndex + 1] = 'b';
@@ -1091,6 +1141,24 @@
   free(s2);
 }
 
+void testWinStrdupContentIsDefined(const char *s, unsigned validIndex) {
+  char *s2 = _strdup(s);
+  char result = s2[1];// no warning
+  free(s2);
+}
+
+void testWcsdupContentIsDefined(const wchar_t *s, unsigned validIndex) {
+  wchar_t *s2 = wcsdup(s);
+  wchar_t result = s2[1];// no warning
+  free(s2);
+}
+
+void testWinWcsdupContentIsDefined(const wchar_t *s, unsigned validIndex) {
+  wchar_t *s2 = _wcsdup(s);
+  wchar_t result = s2[1];// no warning
+  free(s2);
+}
+
 // 
 // Test the system library functions to which the pointer can escape.
 // This tests false positive suppression.
@@ -1444,6 +1512,14 @@
   return strdup(strdup(str)); // expected-warning{{leak}}
 }
 
+char *testWinLeakWithinReturn(char *str) {
+  return _strdup(_strdup(str)); // expected-warning{{leak}}
+}
+
+wchar_t *testWinWideLeakWithinReturn(wchar_t *str) {
+  return _wcsdup(_wcsdup(str)); // expected-warning{{leak}}
+}
+
 void passConstPtr(const char * ptr);
 
 void testPassConstPointer() {
Index: llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -169,11 +169,12 @@
 {
 public:
   MallocChecker()
-  : II_alloca(nullptr), II_malloc(nullptr), II_free(nullptr),
-

Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-03-02 Thread Alexander Riccio via cfe-commits
ariccio added a comment.

Hmm. This seems to be because `wchar_t` is enabled by `-fms-compatibility`.

@aaron.ballman do you have any idea how to define `wchar_t` without 
`-fms-compatibility`?


http://reviews.llvm.org/D17688



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-03-02 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

The second: you should not update the diff. When a patch is uploaded, the 
assumption is that all tests pass:)


http://reviews.llvm.org/D17688



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-03-02 Thread Alexander Riccio via cfe-commits
ariccio added a comment.

In http://reviews.llvm.org/D17688#366883, @zaks.anna wrote:

> Please, do not submit patches for review before they pass all tests.


Whoops, sorry. Should I been a bit clearer that check-all hadn't finished when 
I updated the diff, or should I not update the diff at all until check-all 
finishes?


http://reviews.llvm.org/D17688



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-03-02 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

Please, do not submit patches for review before they pass all tests.


http://reviews.llvm.org/D17688



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-03-02 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

Generate a preprocessed file and keep copying the definitions from there until 
you reach the types compiler knows about.


http://reviews.llvm.org/D17688



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-03-02 Thread Alexander Riccio via cfe-commits
ariccio added a comment.

Hmm, check-all produced a number of issues, which I think stem from the 
following warning:

  File C:\LLVM\llvm\tools\clang\test\Analysis\malloc.c Line 16: unknown type 
name 'wchar_t'

(with a bunch of instances of that)

...so how do I declare/define `wchar_t` properly?


http://reviews.llvm.org/D17688



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-03-02 Thread Anna Zaks via cfe-commits
zaks.anna accepted this revision.
zaks.anna added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!

I can commit this in your behalf.


http://reviews.llvm.org/D17688



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-03-02 Thread Alexander Riccio via cfe-commits
ariccio updated this revision to Diff 49674.
ariccio added a comment.

Added newly checked variants to the malloc checks.

(Running the check-all suite now, will update with results)


http://reviews.llvm.org/D17688

Files:
  llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  llvm/tools/clang/test/Analysis/malloc.c

Index: llvm/tools/clang/test/Analysis/malloc.c
===
--- llvm/tools/clang/test/Analysis/malloc.c
+++ llvm/tools/clang/test/Analysis/malloc.c
@@ -13,9 +13,15 @@
 void *reallocf(void *ptr, size_t size);
 void *calloc(size_t nmemb, size_t size);
 char *strdup(const char *s);
+wchar_t *wcsdup(const wchar_t *s);
 char *strndup(const char *s, size_t n);
 int memcmp(const void *s1, const void *s2, size_t n);
 
+// Windows variants
+char *_strdup(const char *strSource);
+wchar_t *_wcsdup(const wchar_t *strSource);
+void *_alloca(size_t size);
+
 void myfoo(int *p);
 void myfooint(int p);
 char *fooRetPtr();
@@ -55,6 +61,10 @@
   int *p = alloca(sizeof(int));
 } // no warn
 
+void winAllocaTest() {
+  int *p = _alloca(sizeof(int));
+} // no warn
+
 void allocaBuiltinTest() {
   int *p = __builtin_alloca(sizeof(int));
 } // no warn
@@ -210,6 +220,11 @@
   int *p = alloca(0); // no warning
 }
 
+void CheckUseZeroWinAllocatedNoWarn2() {
+  int *p = _alloca(0); // no warning
+}
+
+
 void CheckUseZeroAllocatedNoWarn3() {
   int *p = malloc(0);
   int *q = realloc(p, 8); // no warning
@@ -233,6 +248,11 @@
   return *p; // expected-warning {{Use of zero-allocated memory}}
 }
 
+char CheckUseZeroWinAllocated2() {
+  char *p = _alloca(0);
+  return *p; // expected-warning {{Use of zero-allocated memory}}
+}
+
 void UseZeroAllocated(int *p) {
   if (p)
 *p = 7; // expected-warning {{Use of zero-allocated memory}}
@@ -1076,6 +1096,21 @@
   s2[validIndex + 1] = 'b';
 } // expected-warning {{Potential leak of memory pointed to by}}
 
+void testWinStrdup(const char *s, unsigned validIndex) {
+  char *s2 = _strdup(s);
+  s2[validIndex + 1] = 'b';
+} // expected-warning {{Potential leak of memory pointed to by}}
+
+void testWcsdup(const wchar_t *s, unsigned validIndex) {
+  wchar_t *s2 = wcsdup(s);
+  s2[validIndex + 1] = 'b';
+} // expected-warning {{Potential leak of memory pointed to by}}
+
+void testWinWcsdup(const wchar_t *s, unsigned validIndex) {
+  wchar_t *s2 = _wcsdup(s);
+  s2[validIndex + 1] = 'b';
+} // expected-warning {{Potential leak of memory pointed to by}}
+
 int testStrndup(const char *s, unsigned validIndex, unsigned size) {
   char *s2 = strndup(s, size);
   s2 [validIndex + 1] = 'b';
@@ -1091,6 +1126,24 @@
   free(s2);
 }
 
+void testWinStrdupContentIsDefined(const char *s, unsigned validIndex) {
+  char *s2 = _strdup(s);
+  char result = s2[1];// no warning
+  free(s2);
+}
+
+void testWcsdupContentIsDefined(const wchar_t *s, unsigned validIndex) {
+  wchar_t *s2 = wcsdup(s);
+  wchar_t result = s2[1];// no warning
+  free(s2);
+}
+
+void testWinWcsdupContentIsDefined(const wchar_t *s, unsigned validIndex) {
+  wchar_t *s2 = _wcsdup(s);
+  wchar_t result = s2[1];// no warning
+  free(s2);
+}
+
 // 
 // Test the system library functions to which the pointer can escape.
 // This tests false positive suppression.
@@ -1444,6 +1497,10 @@
   return strdup(strdup(str)); // expected-warning{{leak}}
 }
 
+char *testWinLeakWithinReturn(wchar_t *str) {
+  return _strdup(_strdup(str)); // expected-warning{{leak}}
+}
+
 void passConstPtr(const char * ptr);
 
 void testPassConstPointer() {
Index: llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -169,11 +169,12 @@
 {
 public:
   MallocChecker()
-  : II_alloca(nullptr), II_malloc(nullptr), II_free(nullptr),
-II_realloc(nullptr), II_calloc(nullptr), II_valloc(nullptr),
-II_reallocf(nullptr), II_strndup(nullptr), II_strdup(nullptr),
-II_kmalloc(nullptr), II_if_nameindex(nullptr),
-II_if_freenameindex(nullptr) {}
+  : II_alloca(nullptr), II_win_alloca(nullptr), II_malloc(nullptr),
+II_free(nullptr), II_realloc(nullptr), II_calloc(nullptr),
+II_valloc(nullptr), II_reallocf(nullptr), II_strndup(nullptr),
+II_strdup(nullptr), II_win_strdup(nullptr), II_kmalloc(nullptr),
+II_if_nameindex(nullptr), II_if_freenameindex(nullptr),
+II_wcsdup(nullptr), II_win_wcsdup(nullptr) {}
 
   /// In pessimistic mode, the checker assumes that it does not know which
   /// functions might free the memory.
@@ -231,10 +232,11 @@
   mutable std::unique_ptr BT_MismatchedDealloc;
   mutable std::unique_ptr BT_OffsetFree[CK_NumCheckKinds];
   mutable std::unique_ptr BT_UseZerroAllocated[CK_NumCheckKinds];
-  mutable IdentifierInfo *II_alloca, 

Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-03-02 Thread Alexander Riccio via cfe-commits
ariccio added a comment.

In http://reviews.llvm.org/D17688#366011, @ariccio wrote:

> In http://reviews.llvm.org/D17688#365951, @zaks.anna wrote:
>
> > ls ./clang/test/Analysis/malloc*
>
>
> Ah, ok. Would it be ok if (for _strdup & _alloca) I just do this at the 
> beginning:
>
>   #if defined(_WIN32)
>  
>   #define strdup _strdup
>   #define alloca _alloca
>  
>   #endif //defined(_WIN32)
>


Nevermind. I'm uploading a proper patch in the next few minutes.


http://reviews.llvm.org/D17688



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-03-01 Thread Alexander Riccio via cfe-commits
ariccio added a comment.

In http://reviews.llvm.org/D17688#365951, @zaks.anna wrote:

> ls ./clang/test/Analysis/malloc*


Ah, ok. Would it be ok if (for _strdup & _alloca) I just do this at the 
beginning:

  #if defined(_WIN32)
  
  #define strdup _strdup
  #define alloca _alloca
  
  #endif //defined(_WIN32)


http://reviews.llvm.org/D17688



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-03-01 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

Of cause, we have regression tests for (almost) everything:
ls ./clang/test/Analysis/malloc*


http://reviews.llvm.org/D17688



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-03-01 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

I suggest to update the malloc regression test with these.


http://reviews.llvm.org/D17688



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-03-01 Thread Aaron Ballman via cfe-commits
On Tue, Mar 1, 2016 at 1:42 PM, 
 wrote:
> I'd quite happily add them... but can I do it in another patch? I think I
> could be more thorough that way.

I'm not certain I understand the reasoning, but I also don't have
strong feelings on whether it's this patch or another. I just don't
understand why some functions made it in this patch and not others
(notably, why the lack of _mbsdup, which is documented on the same
page as others you are adding).

> For the same reason, can we list all the microsoft memory allocating
> routines here? There are a thousand routines we might want to add, and then
> a few others (like _dupenv_s, _malloca, and _expand) which are especially
> important to be able to analyze (because they have really tricky APIs), but
> because of their kooky APIs, they're harder to implement checkers for.

By "here", do you mean in this review thread, or as part of this
section of code?

~Aaron

>
> Sincerely,
> Alexander Riccio
> --
> "Change the world or go home."
> about.me/ariccio
>
> If left to my own devices, I will build more.
> ⁂
>
> On Tue, Mar 1, 2016 at 8:38 AM, Aaron Ballman 
> wrote:
>>
>> On Tue, Mar 1, 2016 at 2:16 AM, Alexander Riccio 
>> wrote:
>> > ariccio updated this revision to Diff 49456.
>> > ariccio added a comment.
>> >
>> > Nit addressed.
>> >
>> >
>> > http://reviews.llvm.org/D17688
>> >
>> > Files:
>> >   llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
>> >
>> > Index: llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
>> > ===
>> > --- llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
>> > +++ llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
>> > @@ -169,11 +169,12 @@
>> >  {
>> >  public:
>> >MallocChecker()
>> > -  : II_alloca(nullptr), II_malloc(nullptr), II_free(nullptr),
>> > -II_realloc(nullptr), II_calloc(nullptr), II_valloc(nullptr),
>> > -II_reallocf(nullptr), II_strndup(nullptr), II_strdup(nullptr),
>> > -II_kmalloc(nullptr), II_if_nameindex(nullptr),
>> > -II_if_freenameindex(nullptr) {}
>> > +  : II_alloca(nullptr), II_win_alloca(nullptr), II_malloc(nullptr),
>> > +II_free(nullptr), II_realloc(nullptr), II_calloc(nullptr),
>> > +II_valloc(nullptr), II_reallocf(nullptr), II_strndup(nullptr),
>> > +II_strdup(nullptr), II_win_strdup(nullptr),
>> > II_kmalloc(nullptr),
>> > +II_if_nameindex(nullptr), II_if_freenameindex(nullptr),
>> > +II_wcsdup(nullptr), II_win_wcsdup(nullptr) {}
>> >
>> >/// In pessimistic mode, the checker assumes that it does not know
>> > which
>> >/// functions might free the memory.
>> > @@ -231,10 +232,11 @@
>> >mutable std::unique_ptr BT_MismatchedDealloc;
>> >mutable std::unique_ptr BT_OffsetFree[CK_NumCheckKinds];
>> >mutable std::unique_ptr
>> > BT_UseZerroAllocated[CK_NumCheckKinds];
>> > -  mutable IdentifierInfo *II_alloca, *II_malloc, *II_free, *II_realloc,
>> > - *II_calloc, *II_valloc, *II_reallocf,
>> > *II_strndup,
>> > - *II_strdup, *II_kmalloc, *II_if_nameindex,
>> > - *II_if_freenameindex;
>> > +  mutable IdentifierInfo *II_alloca, *II_win_alloca, *II_malloc,
>> > *II_free,
>> > + *II_realloc, *II_calloc, *II_valloc,
>> > *II_reallocf,
>> > + *II_strndup, *II_strdup, *II_win_strdup,
>> > *II_kmalloc,
>> > + *II_if_nameindex, *II_if_freenameindex,
>> > *II_wcsdup,
>> > + *II_win_wcsdup;
>> >mutable Optional KernelZeroFlagVal;
>> >
>> >void initIdentifierInfo(ASTContext ) const;
>> > @@ -540,9 +542,15 @@
>> >II_valloc = ("valloc");
>> >II_strdup = ("strdup");
>> >II_strndup = ("strndup");
>> > +  II_wcsdup = ("wcsdup");
>> >II_kmalloc = ("kmalloc");
>> >II_if_nameindex = ("if_nameindex");
>> >II_if_freenameindex = ("if_freenameindex");
>> > +
>> > +  //MSVC uses `_`-prefixed instead, so we check for them too.
>> > +  II_win_strdup = ("_strdup");
>> > +  II_win_wcsdup = ("_wcsdup");
>> > +  II_win_alloca = ("_alloca");
>>
>> What about: _mbsdup, _strdup_dbg, _wcsdup_dbg, _aligned_realloc, and
>> the rest? If we're going to add these (which I really support), it
>> would be good to make a comprehensive sweep for the Win32 additions
>> and add them all.
>>
>> ~Aaron
>>
>> >  }
>> >
>> >  bool MallocChecker::isMemFunction(const FunctionDecl *FD, ASTContext
>> > ) const {
>> > @@ -585,7 +593,8 @@
>> >  if (Family == AF_Malloc && CheckAlloc) {
>> >if (FunI == II_malloc || FunI == II_realloc || FunI ==
>> > II_reallocf ||
>> >FunI == II_calloc || FunI == II_valloc || FunI == II_strdup
>> > ||
>> > -  FunI == II_strndup || FunI == II_kmalloc)
>> > +  FunI == II_win_strdup || FunI == II_strndup || FunI ==

Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-03-01 Thread Alexander Riccio via cfe-commits
ariccio added a comment.

Is this patch all clear to go?

I hope I don't sound too pushy - I just don't want to lose momentum here.


http://reviews.llvm.org/D17688



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-03-01 Thread via cfe-commits
I'd quite happily add them... but can I do it in another patch? I think I
could be more thorough that way.

For the same reason, can we list all the microsoft memory allocating
routines here? There are a thousand routines we might want to add, and then
a few others (like _dupenv_s, _malloca, and _expand) which are especially
important to be able to analyze (because they have really tricky APIs), but
*because* of their kooky APIs, they're harder to implement checkers for.

Sincerely,
Alexander Riccio
--
"Change the world or go home."
about.me/ariccio


If left to my own devices, I will build more.
⁂

On Tue, Mar 1, 2016 at 8:38 AM, Aaron Ballman 
wrote:

> On Tue, Mar 1, 2016 at 2:16 AM, Alexander Riccio 
> wrote:
> > ariccio updated this revision to Diff 49456.
> > ariccio added a comment.
> >
> > Nit addressed.
> >
> >
> > http://reviews.llvm.org/D17688
> >
> > Files:
> >   llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
> >
> > Index: llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
> > ===
> > --- llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
> > +++ llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
> > @@ -169,11 +169,12 @@
> >  {
> >  public:
> >MallocChecker()
> > -  : II_alloca(nullptr), II_malloc(nullptr), II_free(nullptr),
> > -II_realloc(nullptr), II_calloc(nullptr), II_valloc(nullptr),
> > -II_reallocf(nullptr), II_strndup(nullptr), II_strdup(nullptr),
> > -II_kmalloc(nullptr), II_if_nameindex(nullptr),
> > -II_if_freenameindex(nullptr) {}
> > +  : II_alloca(nullptr), II_win_alloca(nullptr), II_malloc(nullptr),
> > +II_free(nullptr), II_realloc(nullptr), II_calloc(nullptr),
> > +II_valloc(nullptr), II_reallocf(nullptr), II_strndup(nullptr),
> > +II_strdup(nullptr), II_win_strdup(nullptr), II_kmalloc(nullptr),
> > +II_if_nameindex(nullptr), II_if_freenameindex(nullptr),
> > +II_wcsdup(nullptr), II_win_wcsdup(nullptr) {}
> >
> >/// In pessimistic mode, the checker assumes that it does not know
> which
> >/// functions might free the memory.
> > @@ -231,10 +232,11 @@
> >mutable std::unique_ptr BT_MismatchedDealloc;
> >mutable std::unique_ptr BT_OffsetFree[CK_NumCheckKinds];
> >mutable std::unique_ptr
> BT_UseZerroAllocated[CK_NumCheckKinds];
> > -  mutable IdentifierInfo *II_alloca, *II_malloc, *II_free, *II_realloc,
> > - *II_calloc, *II_valloc, *II_reallocf,
> *II_strndup,
> > - *II_strdup, *II_kmalloc, *II_if_nameindex,
> > - *II_if_freenameindex;
> > +  mutable IdentifierInfo *II_alloca, *II_win_alloca, *II_malloc,
> *II_free,
> > + *II_realloc, *II_calloc, *II_valloc,
> *II_reallocf,
> > + *II_strndup, *II_strdup, *II_win_strdup,
> *II_kmalloc,
> > + *II_if_nameindex, *II_if_freenameindex,
> *II_wcsdup,
> > + *II_win_wcsdup;
> >mutable Optional KernelZeroFlagVal;
> >
> >void initIdentifierInfo(ASTContext ) const;
> > @@ -540,9 +542,15 @@
> >II_valloc = ("valloc");
> >II_strdup = ("strdup");
> >II_strndup = ("strndup");
> > +  II_wcsdup = ("wcsdup");
> >II_kmalloc = ("kmalloc");
> >II_if_nameindex = ("if_nameindex");
> >II_if_freenameindex = ("if_freenameindex");
> > +
> > +  //MSVC uses `_`-prefixed instead, so we check for them too.
> > +  II_win_strdup = ("_strdup");
> > +  II_win_wcsdup = ("_wcsdup");
> > +  II_win_alloca = ("_alloca");
>
> What about: _mbsdup, _strdup_dbg, _wcsdup_dbg, _aligned_realloc, and
> the rest? If we're going to add these (which I really support), it
> would be good to make a comprehensive sweep for the Win32 additions
> and add them all.
>
> ~Aaron
>
> >  }
> >
> >  bool MallocChecker::isMemFunction(const FunctionDecl *FD, ASTContext
> ) const {
> > @@ -585,7 +593,8 @@
> >  if (Family == AF_Malloc && CheckAlloc) {
> >if (FunI == II_malloc || FunI == II_realloc || FunI ==
> II_reallocf ||
> >FunI == II_calloc || FunI == II_valloc || FunI == II_strdup ||
> > -  FunI == II_strndup || FunI == II_kmalloc)
> > +  FunI == II_win_strdup || FunI == II_strndup || FunI ==
> II_wcsdup ||
> > +  FunI == II_win_wcsdup || FunI == II_kmalloc)
> >  return true;
> >  }
> >
> > @@ -600,7 +609,7 @@
> >  }
> >
> >  if (Family == AF_Alloca && CheckAlloc) {
> > -  if (FunI == II_alloca)
> > +  if (FunI == II_alloca || FunI == II_win_alloca)
> >  return true;
> >  }
> >}
> > @@ -789,11 +798,12 @@
> >State = ProcessZeroAllocation(C, CE, 1, State);
> >  } else if (FunI == II_free) {
> >State = FreeMemAux(C, CE, State, 0, false,
> ReleasedAllocatedMemory);
> > -} else if (FunI == 

Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-03-01 Thread Aaron Ballman via cfe-commits
On Tue, Mar 1, 2016 at 2:16 AM, Alexander Riccio  wrote:
> ariccio updated this revision to Diff 49456.
> ariccio added a comment.
>
> Nit addressed.
>
>
> http://reviews.llvm.org/D17688
>
> Files:
>   llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
>
> Index: llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
> ===
> --- llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
> +++ llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
> @@ -169,11 +169,12 @@
>  {
>  public:
>MallocChecker()
> -  : II_alloca(nullptr), II_malloc(nullptr), II_free(nullptr),
> -II_realloc(nullptr), II_calloc(nullptr), II_valloc(nullptr),
> -II_reallocf(nullptr), II_strndup(nullptr), II_strdup(nullptr),
> -II_kmalloc(nullptr), II_if_nameindex(nullptr),
> -II_if_freenameindex(nullptr) {}
> +  : II_alloca(nullptr), II_win_alloca(nullptr), II_malloc(nullptr),
> +II_free(nullptr), II_realloc(nullptr), II_calloc(nullptr),
> +II_valloc(nullptr), II_reallocf(nullptr), II_strndup(nullptr),
> +II_strdup(nullptr), II_win_strdup(nullptr), II_kmalloc(nullptr),
> +II_if_nameindex(nullptr), II_if_freenameindex(nullptr),
> +II_wcsdup(nullptr), II_win_wcsdup(nullptr) {}
>
>/// In pessimistic mode, the checker assumes that it does not know which
>/// functions might free the memory.
> @@ -231,10 +232,11 @@
>mutable std::unique_ptr BT_MismatchedDealloc;
>mutable std::unique_ptr BT_OffsetFree[CK_NumCheckKinds];
>mutable std::unique_ptr BT_UseZerroAllocated[CK_NumCheckKinds];
> -  mutable IdentifierInfo *II_alloca, *II_malloc, *II_free, *II_realloc,
> - *II_calloc, *II_valloc, *II_reallocf, *II_strndup,
> - *II_strdup, *II_kmalloc, *II_if_nameindex,
> - *II_if_freenameindex;
> +  mutable IdentifierInfo *II_alloca, *II_win_alloca, *II_malloc, *II_free,
> + *II_realloc, *II_calloc, *II_valloc, *II_reallocf,
> + *II_strndup, *II_strdup, *II_win_strdup, 
> *II_kmalloc,
> + *II_if_nameindex, *II_if_freenameindex, *II_wcsdup,
> + *II_win_wcsdup;
>mutable Optional KernelZeroFlagVal;
>
>void initIdentifierInfo(ASTContext ) const;
> @@ -540,9 +542,15 @@
>II_valloc = ("valloc");
>II_strdup = ("strdup");
>II_strndup = ("strndup");
> +  II_wcsdup = ("wcsdup");
>II_kmalloc = ("kmalloc");
>II_if_nameindex = ("if_nameindex");
>II_if_freenameindex = ("if_freenameindex");
> +
> +  //MSVC uses `_`-prefixed instead, so we check for them too.
> +  II_win_strdup = ("_strdup");
> +  II_win_wcsdup = ("_wcsdup");
> +  II_win_alloca = ("_alloca");

What about: _mbsdup, _strdup_dbg, _wcsdup_dbg, _aligned_realloc, and
the rest? If we're going to add these (which I really support), it
would be good to make a comprehensive sweep for the Win32 additions
and add them all.

~Aaron

>  }
>
>  bool MallocChecker::isMemFunction(const FunctionDecl *FD, ASTContext ) 
> const {
> @@ -585,7 +593,8 @@
>  if (Family == AF_Malloc && CheckAlloc) {
>if (FunI == II_malloc || FunI == II_realloc || FunI == II_reallocf ||
>FunI == II_calloc || FunI == II_valloc || FunI == II_strdup ||
> -  FunI == II_strndup || FunI == II_kmalloc)
> +  FunI == II_win_strdup || FunI == II_strndup || FunI == II_wcsdup ||
> +  FunI == II_win_wcsdup || FunI == II_kmalloc)
>  return true;
>  }
>
> @@ -600,7 +609,7 @@
>  }
>
>  if (Family == AF_Alloca && CheckAlloc) {
> -  if (FunI == II_alloca)
> +  if (FunI == II_alloca || FunI == II_win_alloca)
>  return true;
>  }
>}
> @@ -789,11 +798,12 @@
>State = ProcessZeroAllocation(C, CE, 1, State);
>  } else if (FunI == II_free) {
>State = FreeMemAux(C, CE, State, 0, false, ReleasedAllocatedMemory);
> -} else if (FunI == II_strdup) {
> +} else if (FunI == II_strdup || FunI == II_win_strdup ||
> +   FunI == II_wcsdup || FunI == II_win_wcsdup) {
>State = MallocUpdateRefState(C, CE, State);
>  } else if (FunI == II_strndup) {
>State = MallocUpdateRefState(C, CE, State);
> -} else if (FunI == II_alloca) {
> +} else if (FunI == II_alloca || FunI == II_win_alloca) {
>State = MallocMemAux(C, CE, CE->getArg(0), UndefinedVal(), State,
> AF_Alloca);
>State = ProcessZeroAllocation(C, CE, 0, State);
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-02-29 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

Nit: Could you change the prefix from "win" to "win_"?


http://reviews.llvm.org/D17688



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-02-28 Thread Alexander Riccio via cfe-commits
ariccio added a comment.

//(This is mostly for my own reference)//
BTW, there are a few other non-MS-only functions in the C standard library that 
allocate memory that needs to be free()d:

1. getcwd (and _getcwd/_wgetcwd)

And some MS-specific functions that I'm surprised are actually MS-only:

1. _getdcwd/_wgetdcwd
2. _dupenv_s/_wdupenv_s
3. _fullpath/_wfullpath




http://reviews.llvm.org/D17688



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-02-28 Thread Alexander Riccio via cfe-commits
ariccio updated this revision to Diff 49330.
ariccio added a comment.

Changed underscore prefixed variable names to `win` prefixed variable names.


http://reviews.llvm.org/D17688

Files:
  llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp

Index: llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -169,11 +169,12 @@
 {
 public:
   MallocChecker()
-  : II_alloca(nullptr), II_malloc(nullptr), II_free(nullptr),
-II_realloc(nullptr), II_calloc(nullptr), II_valloc(nullptr),
-II_reallocf(nullptr), II_strndup(nullptr), II_strdup(nullptr),
-II_kmalloc(nullptr), II_if_nameindex(nullptr),
-II_if_freenameindex(nullptr) {}
+  : II_alloca(nullptr), II_winalloca(nullptr), II_malloc(nullptr),
+II_free(nullptr), II_realloc(nullptr), II_calloc(nullptr),
+II_valloc(nullptr), II_reallocf(nullptr), II_strndup(nullptr),
+II_strdup(nullptr), II_winstrdup(nullptr), II_kmalloc(nullptr),
+II_if_nameindex(nullptr), II_if_freenameindex(nullptr),
+II_wcsdup(nullptr), II_winwcsdup(nullptr) {}
 
   /// In pessimistic mode, the checker assumes that it does not know which
   /// functions might free the memory.
@@ -231,10 +232,11 @@
   mutable std::unique_ptr BT_MismatchedDealloc;
   mutable std::unique_ptr BT_OffsetFree[CK_NumCheckKinds];
   mutable std::unique_ptr BT_UseZerroAllocated[CK_NumCheckKinds];
-  mutable IdentifierInfo *II_alloca, *II_malloc, *II_free, *II_realloc,
- *II_calloc, *II_valloc, *II_reallocf, *II_strndup,
- *II_strdup, *II_kmalloc, *II_if_nameindex,
- *II_if_freenameindex;
+  mutable IdentifierInfo *II_alloca, *II_winalloca, *II_malloc, *II_free,
+ *II_realloc, *II_calloc, *II_valloc, *II_reallocf,
+ *II_strndup, *II_strdup, *II_winstrdup, *II_kmalloc,
+ *II_if_nameindex, *II_if_freenameindex, *II_wcsdup,
+ *II_winwcsdup;
   mutable Optional KernelZeroFlagVal;
 
   void initIdentifierInfo(ASTContext ) const;
@@ -540,9 +542,15 @@
   II_valloc = ("valloc");
   II_strdup = ("strdup");
   II_strndup = ("strndup");
+  II_wcsdup = ("wcsdup");
   II_kmalloc = ("kmalloc");
   II_if_nameindex = ("if_nameindex");
   II_if_freenameindex = ("if_freenameindex");
+  
+  //MSVC uses `_`-prefixed instead, so we check for them too.
+  II_winstrdup = ("_strdup");
+  II_winwcsdup = ("_wcsdup");
+  II_winalloca = ("_alloca");
 }
 
 bool MallocChecker::isMemFunction(const FunctionDecl *FD, ASTContext ) const 
{
@@ -585,7 +593,8 @@
 if (Family == AF_Malloc && CheckAlloc) {
   if (FunI == II_malloc || FunI == II_realloc || FunI == II_reallocf ||
   FunI == II_calloc || FunI == II_valloc || FunI == II_strdup ||
-  FunI == II_strndup || FunI == II_kmalloc)
+  FunI == II_winstrdup || FunI == II_strndup || FunI == II_wcsdup ||
+  FunI == II_winwcsdup || FunI == II_kmalloc)
 return true;
 }
 
@@ -600,7 +609,7 @@
 }
 
 if (Family == AF_Alloca && CheckAlloc) {
-  if (FunI == II_alloca)
+  if (FunI == II_alloca || FunI == II_winalloca)
 return true;
 }
   }
@@ -789,11 +798,12 @@
   State = ProcessZeroAllocation(C, CE, 1, State);
 } else if (FunI == II_free) {
   State = FreeMemAux(C, CE, State, 0, false, ReleasedAllocatedMemory);
-} else if (FunI == II_strdup) {
+} else if (FunI == II_strdup || FunI == II_winstrdup ||
+   FunI == II_wcsdup || FunI == II_winwcsdup) {
   State = MallocUpdateRefState(C, CE, State);
 } else if (FunI == II_strndup) {
   State = MallocUpdateRefState(C, CE, State);
-} else if (FunI == II_alloca) {
+} else if (FunI == II_alloca || FunI == II_winalloca) {
   State = MallocMemAux(C, CE, CE->getArg(0), UndefinedVal(), State,
AF_Alloca);
   State = ProcessZeroAllocation(C, CE, 0, State);


Index: llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -169,11 +169,12 @@
 {
 public:
   MallocChecker()
-  : II_alloca(nullptr), II_malloc(nullptr), II_free(nullptr),
-II_realloc(nullptr), II_calloc(nullptr), II_valloc(nullptr),
-II_reallocf(nullptr), II_strndup(nullptr), II_strdup(nullptr),
-II_kmalloc(nullptr), II_if_nameindex(nullptr),
-II_if_freenameindex(nullptr) {}
+  : II_alloca(nullptr), II_winalloca(nullptr), II_malloc(nullptr),
+II_free(nullptr), II_realloc(nullptr), II_calloc(nullptr),
+II_valloc(nullptr), 

Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-02-28 Thread Alexander Riccio via cfe-commits
ariccio added a comment.

In http://reviews.llvm.org/D17688#363835, @zaks.anna wrote:

> The two underscores in the names are hard to read. Maybe we should just 
> prefix them with 'win'?


I like that better, will change.


http://reviews.llvm.org/D17688



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-02-28 Thread Aaron Ballman via cfe-commits
On Sun, Feb 28, 2016 at 1:21 PM, Anna Zaks  wrote:
> zaks.anna added a comment.
>
> The two underscores in the names are hard to read. Maybe we should just 
> prefix them with 'win'?

Two underscores in the name is actually undefined behavior, so I would
second this suggestion. ;-)

~Aaron
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-02-28 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

The two underscores in the names are hard to read. Maybe we should just prefix 
them with 'win'?


http://reviews.llvm.org/D17688



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits