[PATCH] Fix for aggregate copying of variable length arrays.

Alexey Bataev a.bataev at hotmail.com
Tue May 19 06:41:03 PDT 2015


Hi rjmccall,

Patch fixes codegen for aggregate copying of VLAs. Currently method CodeGenFunction::EmitAggregateCopy() does not support copying of VLAs. Patch checks if the size of the type is 0, then checks if the type is actually a variable-length array. Then it calculates total length for this array and calculates total size of the array in bytes:
```
<total number of elements in array> * aligned_sizeof(ElementType) (if copy assignment is requested).
```
If simple copying is requested, size is calculated like:
```
<total number of elements in array> * aligned_sizeof(ElementType) - aligned_sizeof(ElementType) + sizeof(ElementType).
```
memcpy() is used with this calculated size of the VLA.

http://reviews.llvm.org/D9851

Files:
  lib/CodeGen/CGExprAgg.cpp
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/parallel_firstprivate_codegen.cpp

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9851.26054.patch
Type: text/x-patch
Size: 5098 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150519/e3807e73/attachment.bin>


More information about the cfe-commits mailing list