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

João Matos ripzonetriton at gmail.com
Sat Dec 22 07:48:40 PST 2012


+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.

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


More information about the cfe-dev mailing list