[cfe-commits] r51888 - in /cfe/trunk: include/clang/AST/ExprObjC.h include/clang/AST/StmtNodes.def lib/AST/Expr.cpp lib/AST/StmtPrinter.cpp lib/AST/StmtSerialization.cpp lib/Sema/SemaExpr.cpp test/Sema/objc-property-7.m
Steve Naroff
snaroff at apple.com
Mon Jun 2 16:03:38 PDT 2008
Author: snaroff
Date: Mon Jun 2 18:03:37 2008
New Revision: 51888
URL: http://llvm.org/viewvc/llvm-project?rev=51888&view=rev
Log:
Fix <rdar://problem/5979875> clang on xcode: error: use of undeclared identifier 'super'
Added:
cfe/trunk/test/Sema/objc-property-7.m
Modified:
cfe/trunk/include/clang/AST/ExprObjC.h
cfe/trunk/include/clang/AST/StmtNodes.def
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/AST/StmtSerialization.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
Modified: cfe/trunk/include/clang/AST/ExprObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprObjC.h?rev=51888&r1=51887&r2=51888&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprObjC.h (original)
+++ cfe/trunk/include/clang/AST/ExprObjC.h Mon Jun 2 18:03:37 2008
@@ -335,6 +335,28 @@
static ObjCMessageExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
};
+/// ObjCSuperRefExpr - A reference to super.
+class ObjCSuperRefExpr : public Expr {
+ SourceLocation Loc;
+public:
+ ObjCSuperRefExpr(QualType t, SourceLocation l) :
+ Expr(ObjCSuperRefExprClass, t), Loc(l) {}
+
+ virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == ObjCSuperRefExprClass;
+ }
+ static bool classof(const ObjCSuperRefExpr *) { return true; }
+
+ // Iterators
+ virtual child_iterator child_begin();
+ virtual child_iterator child_end();
+
+ virtual void EmitImpl(llvm::Serializer& S) const;
+ static ObjCSuperRefExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
+};
+
} // end namespace clang
#endif
Modified: cfe/trunk/include/clang/AST/StmtNodes.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtNodes.def?rev=51888&r1=51887&r2=51888&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/StmtNodes.def (original)
+++ cfe/trunk/include/clang/AST/StmtNodes.def Mon Jun 2 18:03:37 2008
@@ -101,12 +101,13 @@
STMT(74, ObjCProtocolExpr , Expr)
STMT(75, ObjCIvarRefExpr , Expr)
STMT(76, ObjCPropertyRefExpr , Expr)
+STMT(77, ObjCSuperRefExpr , Expr)
// Clang Extensions.
-STMT(77, OverloadExpr , Expr)
-STMT(78, ShuffleVectorExpr , Expr)
+STMT(78, OverloadExpr , Expr)
+STMT(79, ShuffleVectorExpr , Expr)
-LAST_EXPR(78)
+LAST_EXPR(79)
#undef STMT
#undef FIRST_STMT
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=51888&r1=51887&r2=51888&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Mon Jun 2 18:03:37 2008
@@ -1189,7 +1189,7 @@
return reinterpret_cast<Stmt**>(&Base)+1;
}
-// ObjCIvarRefExpr
+// ObjCPropertyRefExpr
Stmt::child_iterator ObjCPropertyRefExpr::child_begin() {
return reinterpret_cast<Stmt**>(&Base);
}
@@ -1198,6 +1198,10 @@
return reinterpret_cast<Stmt**>(&Base)+1;
}
+// ObjCSuperRefExpr
+Stmt::child_iterator ObjCSuperRefExpr::child_begin() { return child_iterator();}
+Stmt::child_iterator ObjCSuperRefExpr::child_end() { return child_iterator(); }
+
// PreDefinedExpr
Stmt::child_iterator PreDefinedExpr::child_begin() { return child_iterator(); }
Stmt::child_iterator PreDefinedExpr::child_end() { return child_iterator(); }
Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=51888&r1=51887&r2=51888&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Mon Jun 2 18:03:37 2008
@@ -476,6 +476,10 @@
OS << Node->getDecl()->getName();
}
+void StmtPrinter::VisitObjCSuperRefExpr(ObjCSuperRefExpr *Node) {
+ OS << "super";
+}
+
void StmtPrinter::VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node) {
if (Node->getBase()) {
PrintExpr(Node->getBase());
Modified: cfe/trunk/lib/AST/StmtSerialization.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtSerialization.cpp?rev=51888&r1=51887&r2=51888&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtSerialization.cpp (original)
+++ cfe/trunk/lib/AST/StmtSerialization.cpp Mon Jun 2 18:03:37 2008
@@ -518,6 +518,17 @@
return new DeclRefExpr(decl,T,Loc);
}
+void ObjCSuperRefExpr::EmitImpl(Serializer& S) const {
+ S.Emit(Loc);
+ S.Emit(getType());
+}
+
+ObjCSuperRefExpr* ObjCSuperRefExpr::CreateImpl(Deserializer& D, ASTContext& C) {
+ SourceLocation Loc = SourceLocation::ReadVal(D);
+ QualType T = QualType::ReadVal(D);
+ return new ObjCSuperRefExpr(T, Loc);
+}
+
DeclStmt* DeclStmt::CreateImpl(Deserializer& D, ASTContext& C) {
ScopedDecl* decl = cast<ScopedDecl>(D.ReadOwnedPtr<Decl>(C));
SourceLocation StartLoc = SourceLocation::ReadVal(D);
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=51888&r1=51887&r2=51888&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Jun 2 18:03:37 2008
@@ -99,6 +99,11 @@
static_cast<Expr*>(SelfExpr.Val), true, true);
}
}
+ if (!strncmp(II.getName(), "super", 5)) {
+ QualType T = Context.getPointerType(Context.getObjCInterfaceType(
+ CurMethodDecl->getClassInterface()));
+ return new ObjCSuperRefExpr(T, Loc);
+ }
}
if (D == 0) {
Added: cfe/trunk/test/Sema/objc-property-7.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/objc-property-7.m?rev=51888&view=auto
==============================================================================
--- cfe/trunk/test/Sema/objc-property-7.m (added)
+++ cfe/trunk/test/Sema/objc-property-7.m Mon Jun 2 18:03:37 2008
@@ -0,0 +1,34 @@
+// RUN: clang -fsyntax-only -verify %s
+typedef signed char BOOL;
+typedef struct _NSZone NSZone;
+
+ at protocol NSObject
+- (BOOL)isEqual:(id)object;
+ at end
+
+ at protocol NSCopying
+- (id)copyWithZone:(NSZone *)zone;
+ at end
+
+ at interface NSObject <NSObject> {}
+ at end
+
+ at class NSString, NSData, NSMutableData, NSMutableDictionary, NSMutableArray;
+
+ at interface SCMObject : NSObject <NSCopying> {}
+ @property(assign) SCMObject *__attribute__((objc_gc(weak))) parent;
+ at end
+
+ at interface SCMNode : SCMObject
+{
+ NSString *_name;
+}
+ at property(copy) NSString *name;
+ at end
+
+ at implementation SCMNode
+ @synthesize name = _name;
+ - (void) setParent:(SCMNode*) inParent {
+ super.parent = inParent;
+ }
+ at end
More information about the cfe-commits
mailing list