[cfe-commits] PFR: "Fix" arrow dereferencing for assignment

Oliver Hunt oliver at apple.com
Sun Dec 2 03:40:45 PST 2007


Okay, this isn't something i'm sure about because i honestly cannot  
work out what the original code was attempting to do.

This bug would occur when trying to assign to a member through an  
arrow dereference, as in:
expression_t *create_expression() {
     expression_t *expr = (expression_t*)malloc(sizeof(expression_t));
     expr->nChildren = 0;
     return expr;
}

This would produce
define %struct.expression_s* @create_expression() {
entry:
	%expr = alloca %struct.expression_s*		; <%struct.expression_s**>  
[#uses=3]
...
	%tmp = bitcast %struct.expression_s** %expr to  
%struct.expression_s*		; <%struct.expression_s*> [#uses=1]
...
}

Where it cast to the appropriate type rather than doing a load.

the obvious solution is to replace CreateBitCast with CreateLoad (what  
this patch does), but i can't help
but worry that someone has done this deliberately at some point, and  
i'm just missing something important :-/



--Oliver

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20071202/ae4fbe8a/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix-arrow-dereference.patch
Type: application/octet-stream
Size: 637 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20071202/ae4fbe8a/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20071202/ae4fbe8a/attachment-0001.html>


More information about the cfe-commits mailing list