[cfe-dev] [RFC] Preliminary patch to support MSVC __declspec(property)
Richard Smith
richard at metafoo.co.uk
Fri Dec 28 05:46:38 PST 2012
On Sat, Dec 22, 2012 at 7:56 AM, endlessroad1991 at gmail.com
<endlessroad1991 at gmail.com> wrote:
>
>
> On Sat, Dec 22, 2012 at 11:48 PM, João Matos <ripzonetriton at gmail.com>
> wrote:
>>
>> +class MSPropertyDecl : public DeclaratorDecl {
>> +public:
>> + MSPropertyDecl(Kind DK, DeclContext *DC, SourceLocation L,
>> + DeclarationName N, QualType T, TypeSourceInfo *TInfo,
>> + SourceLocation StartL, llvm::StringRef Getter,
>> + llvm::StringRef Setter):
>> + DeclaratorDecl(DK, DC, L, N, T, TInfo, StartL), GetterName(Getter),
>> + SetterName(Setter) {}
>> +
>> + static bool classof(const Decl *D) { return D->getKind() == MSProperty;
>> }
>> +
>> + bool hasGetter() { return !GetterName.empty(); }
>> + llvm::StringRef getGetterName() { return GetterName; }
>> + bool hasSetter() { return !SetterName.empty(); }
>> + llvm::StringRef getSetterName() { return SetterName; }
>> +
>> +private:
>> + llvm::StringRef GetterName, SetterName;
>> +};
>>
>> Why are you storing the getter and setter as StringRef in MSPropertyDecl?
>>
>> I think it would make more sense to lookup them up under Sema and store
>> the AST node directly. Also the private members should be at the top of the
>> class to be consistent with the rest of the AST code conventions.
>
>
> Getter/Setter can be defined after property. So when we're parsing property,
> getter/setter may not be available yet.
Then this should be either an IdentifierInfo* or a DeclarationName.
Does MSVC allow more exotic unqualified-ids as accessors? For
instance,
struct S {
operator int() const;
S &operator=(int);
__declspec(property(get=operator int, put=operator=)) int x;
};
> However, we can cache the search result into MSPropertyDecl to speedup
> following search.
Right, using a PointerUnion<const IdentifierInfo*, CXXMethodDecl*>
might make sense here.
>> +void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
>> + llvm_unreachable("Shouldn't get here");
>> +}
>>
>> +void ASTStmtWriter::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
>> + llvm_unreachable("Shouldn't get here");
>> +}
>>
>> These should be implemented.
>>
>> The parsing code seems to do more string comparisons than are necessary
>> but since this feature is not that common it might be fine, I'll leave that
>> for other people to comment.
>>
>> --
>> João Matos
>
>
>
>
> --
> Best Regards, Tong Shen (沈彤)
>
> _______________________________________________
> 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