[cfe-dev] [Patch] visit order of InitListExpr

Jin Gu Kang jaykang10 at imrc.kist.re.kr
Tue Sep 4 16:40:11 PDT 2012

Hi all,

I checked "VisitInitListExpr(InitListExpr *ILE)" function and found strange type checking order. Current type checking order is as following.

 829   llvm::Constant *VisitInitListExpr(InitListExpr *ILE) {
 830     if (ILE->getType()->isArrayType())
 831       return EmitArrayInitialization(ILE);
 833     if (ILE->getType()->isRecordType())
 834       return EmitUnionInitialization(ILE);
 836     if (ILE->getType()->isUnionType())
 837       return EmitStructInitialization(ILE);
If RecodeType is checked eariler, UnionType will not be check because UnionType is checked from Decl's field and Type is also RecordType. Although EmitStructInitialization() and EmitUnionInitialization() call the same ConstStructBuilder::BuildStruct() function, It looks like wrong. I think UnionType should be checked eariler than RecordType.

What do you think about this?

I attach a simple patch to fix it.

Jin-Gu Kang

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120905/fd895d4b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang.patch
Type: application/octet-stream
Size: 599 bytes
Desc: clang.patch
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120905/fd895d4b/attachment.obj>

More information about the cfe-dev mailing list