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

endlessroad1991 at gmail.com endlessroad1991 at gmail.com
Sat Dec 22 07:56:38 PST 2012


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.
However, we can cache the search result into MSPropertyDecl to speedup
following search.


>
> +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 (沈彤)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121222/1710cbec/attachment.html>


More information about the cfe-dev mailing list