From ab468b03815a8454b4bda1e5b4f20bc1ad7f1857 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Fri, 30 Mar 2012 00:19:18 +0000 Subject: Add info to ObjCPropertyRefExpr to indicate whether the dot syntax property reference is going to message the setter, the getter, or both. Having this info on the ObjCPropertyRefExpr node makes it easier for AST clients (like libclang) to reason about the meaning of the property reference. [AST/Sema] -Use 2 bits (with a PointerIntPair) in ObjCPropertyRefExpr to record the above info -Have ObjCPropertyOpBuilder set the info appropriately. [libclang] -When there is an implicit property reference (property syntax using methods) have clang_getCursorReferenced return a cursor for the method. If the property reference is going to result in messaging both the getter and the setter choose to return a cursor for the setter because it is less obvious from source inspection that the setter is getting called. The general idea has the seal of approval by John. rdar://11151621 llvm-svn: 153709 --- clang/lib/Serialization/ASTReaderStmt.cpp | 6 ++++-- clang/lib/Serialization/ASTWriterStmt.cpp | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'clang/lib/Serialization') diff --git a/clang/lib/Serialization/ASTReaderStmt.cpp b/clang/lib/Serialization/ASTReaderStmt.cpp index d8289f227f5..1c9817b955d 100644 --- a/clang/lib/Serialization/ASTReaderStmt.cpp +++ b/clang/lib/Serialization/ASTReaderStmt.cpp @@ -887,13 +887,15 @@ void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) { void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) { VisitExpr(E); + unsigned MethodRefFlags = Record[Idx++]; bool Implicit = Record[Idx++] != 0; if (Implicit) { ObjCMethodDecl *Getter = ReadDeclAs(Record, Idx); ObjCMethodDecl *Setter = ReadDeclAs(Record, Idx); - E->setImplicitProperty(Getter, Setter); + E->setImplicitProperty(Getter, Setter, MethodRefFlags); } else { - E->setExplicitProperty(ReadDeclAs(Record, Idx)); + E->setExplicitProperty(ReadDeclAs(Record, Idx), + MethodRefFlags); } E->setLocation(ReadSourceLocation(Record, Idx)); E->setReceiverLocation(ReadSourceLocation(Record, Idx)); diff --git a/clang/lib/Serialization/ASTWriterStmt.cpp b/clang/lib/Serialization/ASTWriterStmt.cpp index 791403b5a22..eac7e1fb730 100644 --- a/clang/lib/Serialization/ASTWriterStmt.cpp +++ b/clang/lib/Serialization/ASTWriterStmt.cpp @@ -851,6 +851,7 @@ void ASTStmtWriter::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) { void ASTStmtWriter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) { VisitExpr(E); + Record.push_back(E->SetterAndMethodRefFlags.getInt()); Record.push_back(E->isImplicitProperty()); if (E->isImplicitProperty()) { Writer.AddDeclRef(E->getImplicitPropertyGetter(), Record); -- cgit v1.2.3