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

Sebastian Redl sebastian.redl at getdesigned.at
Wed Sep 5 00:41:45 PDT 2012


On 04.09.2012, at 08:43, Jin Gu Kang wrote:

> 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);
>  832
>  833     if (ILE->getType()->isRecordType())
>  834       return EmitUnionInitialization(ILE);
>  835
>  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.

Looks good, go ahead.

Sebastian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120905/3f661e13/attachment.html>


More information about the cfe-dev mailing list