Yes, if we put it in CodeGen, we still have to do much work which is Sema's responsibility, and that's ugly.<div><br></div><div>I looked into pseudo objects and ObjC property implementation.I see that set is handled in Sema::BuildBinOp(which calls Sema::checkPseudoObjectAssignment), and get is handled in Sema::CheckPlaceHolder, which is called in many places. And we are sure that L-Value property(thus set) won't be rewritten to getter call, because Sema::CheckPlaceHolder will only handle R-Value situations.</div>
<div><br></div><div>Are these "deductions" correct? If so, I will reimplement property using pseudo objects.</div><div>Thanks for the info!</div><div><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Fri, Dec 7, 2012 at 9:30 AM, John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On Dec 6, 2012, at 9:52 AM, <a href="mailto:endlessroad1991@gmail.com">endlessroad1991@gmail.com</a> wrote:<br>
> Hey guys, I've worked out a preliminary patch to support MSVC __declspec(property), based on 3.2RC2.<br>
> Patch and a simple test cpp file attached. Please compile the test case with -fms-extensions.<br>
><br>
> Current status:<br>
> - Support getter/setter<br>
> - Support template (see attached test file)<br>
> - No support for +=, -=, etc<br>
> - No support for implicit type conversion for arguments of getter/setter functions<br>
><br>
> Brief introduction on implementation:<br>
> 1. Let Parser parse property declaration.<br>
> 2. Add a "PropertyAttr" class to store getter/putter function names.<br>
> 3. Notice that there can be "[]" after property declaration, and number of "[]" indicates number of args for getter/setter function(see attached test file). Add a field to QualType to store number of "[]". I know it's horrible, but for a working prototype, that's enough.<br>

> 4. Add a "MSPropertyExpr". When we encounter property usage in Parser, we don't know whether it's get or set. So we have to add an action AFTER Sema, or do it in CodeGen. Either way, while parsing, all we know is arguments for getter/setter.<br>

> 5. In CodeGen, deal with "MSPropertyExpr". If it's "scalar" in CodeGen, it's a get, replace it with a CallExpr to getter. If it's "LValue" on the left side of an assignment, replace the whole assignment with a CallExpr to setter.<br>

><br>
> I know the timing is really bad..<br>
> But, any comments?<br>
<br>
</div></div>Handling this in IR-generation is not a great idea;  we did this for Objective-C properties for a very long time and eventually got fed up with it.  You should look into pseudo-object expressions;  I actually had this language extension in the back of my mind when I was designing them.<br>

<span class="HOEnZb"><font color="#888888"><br>
John.<br>
<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>Best Regards, Tong Shen (沈彤)<br>
</div>