This revision was automatically updated to reflect the committed changes.
Closed by commit rGf0e102c1a39f: [analyzer][NFC] Add tests for extents 
(authored by Balazs Benics <balazsben...@sigmatechnology.se>).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99959/new/

https://reviews.llvm.org/D99959

Files:
  clang/test/Analysis/malloc.c


Index: clang/test/Analysis/malloc.c
===================================================================
--- clang/test/Analysis/malloc.c
+++ clang/test/Analysis/malloc.c
@@ -8,6 +8,8 @@
 #include "Inputs/system-header-simulator.h"
 
 void clang_analyzer_eval(int);
+void clang_analyzer_dump(int);
+void clang_analyzer_dumpExtent(void *);
 
 // 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
@@ -1883,3 +1885,14 @@
   s->memP = malloc(sizeof(int));
   free(s);
 } // FIXME: should warn here
+
+int conjure();
+void testExtent() {
+  int x = conjure();
+  clang_analyzer_dump(x);
+  // expected-warning-re@-1 {{{{^conj_\$[[:digit:]]+{int, LC1, S[[:digit:]]+, 
#1}}}}}}
+  int *p = (int *)malloc(x);
+  clang_analyzer_dumpExtent(p);
+  // expected-warning-re@-1 {{{{^conj_\$[[:digit:]]+{int, LC1, S[[:digit:]]+, 
#1}}}}}}
+  free(p);
+}


Index: clang/test/Analysis/malloc.c
===================================================================
--- clang/test/Analysis/malloc.c
+++ clang/test/Analysis/malloc.c
@@ -8,6 +8,8 @@
 #include "Inputs/system-header-simulator.h"
 
 void clang_analyzer_eval(int);
+void clang_analyzer_dump(int);
+void clang_analyzer_dumpExtent(void *);
 
 // 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
@@ -1883,3 +1885,14 @@
   s->memP = malloc(sizeof(int));
   free(s);
 } // FIXME: should warn here
+
+int conjure();
+void testExtent() {
+  int x = conjure();
+  clang_analyzer_dump(x);
+  // expected-warning-re@-1 {{{{^conj_\$[[:digit:]]+{int, LC1, S[[:digit:]]+, #1}}}}}}
+  int *p = (int *)malloc(x);
+  clang_analyzer_dumpExtent(p);
+  // expected-warning-re@-1 {{{{^conj_\$[[:digit:]]+{int, LC1, S[[:digit:]]+, #1}}}}}}
+  free(p);
+}
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to