gAlfonso-bit updated this revision to Diff 534244.

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

https://reviews.llvm.org/D148958

Files:
  clang/test/Analysis/malloc.mm
  clang/test/Analysis/uninit-vals.m
  clang/test/CodeGen/alloc-size.c
  compiler-rt/lib/profile/InstrProfilingFile.c
  compiler-rt/test/tsan/java_finalizer2.cpp
  flang/runtime/ragged.cpp

Index: flang/runtime/ragged.cpp
===================================================================
--- flang/runtime/ragged.cpp
+++ flang/runtime/ragged.cpp
@@ -32,10 +32,9 @@
     header->flags = (rank << 1) | isHeader;
     header->extentPointer = extentVector;
     if (isHeader) {
-      header->bufferPointer = std::calloc(sizeof(RaggedArrayHeader), size);
+      header->bufferPointer = std::calloc(size, sizeof(RaggedArrayHeader));
     } else {
-      header->bufferPointer =
-          static_cast<void *>(std::calloc(elementSize, size));
+      header->bufferPointer = std::calloc(size, elementSize);
     }
     return header;
   } else {
Index: compiler-rt/test/tsan/java_finalizer2.cpp
===================================================================
--- compiler-rt/test/tsan/java_finalizer2.cpp
+++ compiler-rt/test/tsan/java_finalizer2.cpp
@@ -51,7 +51,7 @@
 }
 
 int main() {
-  Heap* heap = (Heap*)calloc(sizeof(Heap), 2) + 1;
+  Heap* heap = (Heap*)calloc(2, sizeof(Heap)) + 1;
   __tsan_java_init((jptr)heap, sizeof(*heap));
   __tsan_java_alloc((jptr)heap, sizeof(*heap));
   // Ballast threads merely make the bug a bit easier to trigger.
Index: compiler-rt/lib/profile/InstrProfilingFile.c
===================================================================
--- compiler-rt/lib/profile/InstrProfilingFile.c
+++ compiler-rt/lib/profile/InstrProfilingFile.c
@@ -293,10 +293,10 @@
 COMPILER_RT_VISIBILITY ProfBufferIO *
 lprofCreateBufferIOInternal(void *File, uint32_t BufferSz) {
   FreeHook = &free;
-  DynamicBufferIOBuffer = (uint8_t *)calloc(BufferSz, 1);
+  DynamicBufferIOBuffer = (uint8_t *)calloc(1, BufferSz);
   VPBufferSize = BufferSz;
   ProfDataWriter *fileWriter =
-      (ProfDataWriter *)calloc(sizeof(ProfDataWriter), 1);
+      (ProfDataWriter *)calloc(1, sizeof(ProfDataWriter));
   initFileWriter(fileWriter, File);
   ProfBufferIO *IO = lprofCreateBufferIO(fileWriter);
   IO->OwnFileWriter = 1;
Index: clang/test/CodeGen/alloc-size.c
===================================================================
--- clang/test/CodeGen/alloc-size.c
+++ clang/test/CodeGen/alloc-size.c
@@ -137,7 +137,7 @@
   // CHECK: store i32 36
   gi = OBJECT_SIZE_BUILTIN(&data->t[1], 3);
 
-  struct Data *const arr = my_calloc(sizeof(*data), 2);
+  struct Data *const arr = my_calloc(2, sizeof(*data));
   // CHECK: store i32 96
   gi = OBJECT_SIZE_BUILTIN(arr, 0);
   // CHECK: store i32 96
@@ -171,7 +171,7 @@
   // CHECK: store i32 11
   gi = OBJECT_SIZE_BUILTIN(data->end, 3);
 
-  struct Data *const arr = my_calloc(sizeof(*arr) + 5, 3);
+  struct Data *const arr = my_calloc(3, sizeof(*arr) + 5);
   // AFAICT, GCC treats malloc and calloc identically. So, we should do the
   // same.
   //
Index: clang/test/Analysis/uninit-vals.m
===================================================================
--- clang/test/Analysis/uninit-vals.m
+++ clang/test/Analysis/uninit-vals.m
@@ -158,7 +158,7 @@
 }
 
 void PR14765_test(void) {
-  Circle *testObj = calloc(sizeof(Circle), 1);
+  Circle *testObj = calloc(1, sizeof(Circle));
 
   clang_analyzer_eval(testObj->size == 0); // expected-warning{{TRUE}}
                                            // expected-note@-1{{TRUE}}
@@ -207,7 +207,7 @@
 }
 
 void PR14765_test_int(void) {
-  IntCircle *testObj = calloc(sizeof(IntCircle), 1);
+  IntCircle *testObj = calloc(1, sizeof(IntCircle));
 
   clang_analyzer_eval(testObj->size == 0); // expected-warning{{TRUE}}
                                            // expected-note@-1{{TRUE}}
@@ -311,7 +311,7 @@
 }
 
 void testSmallStructInLargerStruct(void) {
-  IntCircle2D *testObj = calloc(sizeof(IntCircle2D), 1);
+  IntCircle2D *testObj = calloc(1, sizeof(IntCircle2D));
 
   clang_analyzer_eval(testObj->size == 0); // expected-warning{{TRUE}}
                                            // expected-note@-1{{TRUE}}
Index: clang/test/Analysis/malloc.mm
===================================================================
--- clang/test/Analysis/malloc.mm
+++ clang/test/Analysis/malloc.mm
@@ -116,17 +116,17 @@
 }
 
 void testNoCopy() {
-  char *p = (char *)calloc(sizeof(int), 1);
+  char *p = (char *)calloc(1, sizeof(int));
   CustomData *w = [CustomData somethingNoCopy:p]; // no-warning
 }
 
 void testFreeWhenDone() {
-  char *p = (char *)calloc(sizeof(int), 1);
+  char *p = (char *)calloc(1, sizeof(int));
   CustomData *w = [CustomData something:p freeWhenDone:1]; // no-warning
 }
 
 void testFreeWhenDonePositive() {
-  char *p = (char *)calloc(sizeof(int), 1);
+  char *p = (char *)calloc(1, sizeof(int));
   CustomData *w = [CustomData something:p freeWhenDone:0]; // expected-warning{{leak}}
 }
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to