[cfe-dev] [RFC] Preliminary patch to support MSVC __declspec(property)

Sharlet, Dillon dillon.sharlet at intel.com
Thu Dec 6 14:42:55 PST 2012


This feature is used in MFC, which may be a big reason why Clang cannot handle those headers, and possibly other windows headers as well. I think I remember MFC issues coming up from time to time on this mailing list.

Also, this feature would be helpful to implement C++ AMP with better compatibility, which is a project I'm working on (presented at the recent LLVM Developer's Meeting if you want more information).

Regards,
Dillon

-----Original Message-----
From: cfe-dev-bounces at cs.uiuc.edu [mailto:cfe-dev-bounces at cs.uiuc.edu] On Behalf Of Nikola Smiljanic
Sent: Thursday, December 06, 2012 2:16 PM
To: endlessroad1991 at gmail.com
Cc: cfe-dev at cs.uiuc.edu
Subject: Re: [cfe-dev] [RFC] Preliminary patch to support MSVC __declspec(property)

Clang has a policy of only supporting compatibility features that are widely used. Is there a large codebase that depends on this, and has this been discussed?

As for the patch itself, the test should be a part of it, I can't comment the implementation. Have a look at the existing test, it should have something like this at he top

// RUN: %clang_cc1 -fsyntax-only -verify %s -ms-compatibility // expected-no-diagnostics


On Fri, Dec 7, 2012 at 4:52 AM, endlessroad1991 at gmail.com <endlessroad1991 at gmail.com> wrote:
> Hey guys, I've worked out a preliminary patch to support MSVC 
> __declspec(property), based on 3.2RC2.
> Patch and a simple test cpp file attached. Please compile the test 
> case with -fms-extensions.
>
> Current status:
> - Support getter/setter
> - Support template (see attached test file)
> - No support for +=, -=, etc
> - No support for implicit type conversion for arguments of 
> getter/setter functions
>
> Brief introduction on implementation:
> 1. Let Parser parse property declaration.
> 2. Add a "PropertyAttr" class to store getter/putter function names.
> 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.
> 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.
> 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.
>
> I know the timing is really bad..
> But, any comments?
>
> --
> Best Regards, Tong Shen (沈彤)
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>

_______________________________________________
cfe-dev mailing list
cfe-dev at cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list