Fix for aggregate copying of variable length arrays.
authorAlexey Bataev <a.bataev@hotmail.com>
Wed, 20 May 2015 03:46:04 +0000 (03:46 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Wed, 20 May 2015 03:46:04 +0000 (03:46 +0000)
commit16dc7b68c4d90cd3abac7015c27030f3d6c710f9
tree88c7090be664baa4ac9b397a65a20821304d4e8c
parent1f294fd934c17ec9836cbde8293d3c51974cdb05
Fix for aggregate copying of variable length arrays.

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.
Differential Revision: http://reviews.llvm.org/D9851

llvm-svn: 237768
clang/lib/CodeGen/CGExprAgg.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/parallel_firstprivate_codegen.cpp