summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/Expr.cpp4
-rw-r--r--clang/lib/AST/StmtPrinter.cpp5
-rw-r--r--clang/lib/Frontend/PCHReaderStmt.cpp12
-rw-r--r--clang/lib/Frontend/PCHWriterStmt.cpp9
-rw-r--r--clang/lib/Sema/SemaExpr.cpp14
-rw-r--r--clang/lib/Sema/SemaTemplateInstantiateExpr.cpp6
6 files changed, 48 insertions, 2 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index efc37f768cf..b7b0a041e33 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -1878,6 +1878,10 @@ Stmt::child_iterator ObjCKVCRefExpr::child_end() { return &Base+1; }
Stmt::child_iterator ObjCSuperExpr::child_begin() { return child_iterator(); }
Stmt::child_iterator ObjCSuperExpr::child_end() { return child_iterator(); }
+// ObjCIsaExpr
+Stmt::child_iterator ObjCIsaExpr::child_begin() { return &Base; }
+Stmt::child_iterator ObjCIsaExpr::child_end() { return &Base+1; }
+
// PredefinedExpr
Stmt::child_iterator PredefinedExpr::child_begin() { return child_iterator(); }
Stmt::child_iterator PredefinedExpr::child_end() { return child_iterator(); }
diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp
index 26732d4d296..a5b0df8e45c 100644
--- a/clang/lib/AST/StmtPrinter.cpp
+++ b/clang/lib/AST/StmtPrinter.cpp
@@ -739,6 +739,11 @@ void StmtPrinter::VisitMemberExpr(MemberExpr *Node) {
// representing anonymous unions/structs
OS << Node->getMemberDecl()->getNameAsString();
}
+void StmtPrinter::VisitObjCIsaExpr(ObjCIsaExpr *Node) {
+ PrintExpr(Node->getBase());
+ OS << (Node->isArrow() ? "->isa" : ".isa");
+}
+
void StmtPrinter::VisitExtVectorElementExpr(ExtVectorElementExpr *Node) {
PrintExpr(Node->getBase());
OS << ".";
diff --git a/clang/lib/Frontend/PCHReaderStmt.cpp b/clang/lib/Frontend/PCHReaderStmt.cpp
index 5681b675a2d..16c0e79f4e7 100644
--- a/clang/lib/Frontend/PCHReaderStmt.cpp
+++ b/clang/lib/Frontend/PCHReaderStmt.cpp
@@ -104,6 +104,7 @@ namespace {
unsigned VisitObjCKVCRefExpr(ObjCKVCRefExpr *E);
unsigned VisitObjCMessageExpr(ObjCMessageExpr *E);
unsigned VisitObjCSuperExpr(ObjCSuperExpr *E);
+ unsigned VisitObjCIsaExpr(ObjCIsaExpr *E);
unsigned VisitObjCForCollectionStmt(ObjCForCollectionStmt *);
unsigned VisitObjCAtCatchStmt(ObjCAtCatchStmt *);
@@ -448,6 +449,14 @@ unsigned PCHStmtReader::VisitMemberExpr(MemberExpr *E) {
return 1;
}
+unsigned PCHStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
+ VisitExpr(E);
+ E->setBase(cast<Expr>(StmtStack.back()));
+ E->setIsaMemberLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
+ E->setArrow(Record[Idx++]);
+ return 1;
+}
+
unsigned PCHStmtReader::VisitCastExpr(CastExpr *E) {
VisitExpr(E);
E->setSubExpr(cast<Expr>(StmtStack.back()));
@@ -1106,6 +1115,9 @@ Stmt *PCHReader::ReadStmt(llvm::BitstreamCursor &Cursor) {
case pch::EXPR_OBJC_SUPER_EXPR:
S = new (Context) ObjCSuperExpr(Empty);
break;
+ case pch::EXPR_OBJC_ISA:
+ S = new (Context) ObjCIsaExpr(Empty);
+ break;
case pch::STMT_OBJC_FOR_COLLECTION:
S = new (Context) ObjCForCollectionStmt(Empty);
break;
diff --git a/clang/lib/Frontend/PCHWriterStmt.cpp b/clang/lib/Frontend/PCHWriterStmt.cpp
index ae606b6b411..3e4c6f5fedf 100644
--- a/clang/lib/Frontend/PCHWriterStmt.cpp
+++ b/clang/lib/Frontend/PCHWriterStmt.cpp
@@ -97,6 +97,7 @@ namespace {
void VisitObjCKVCRefExpr(ObjCKVCRefExpr *E);
void VisitObjCMessageExpr(ObjCMessageExpr *E);
void VisitObjCSuperExpr(ObjCSuperExpr *E);
+ void VisitObjCIsaExpr(ObjCIsaExpr *E);
// Objective-C Statements
void VisitObjCForCollectionStmt(ObjCForCollectionStmt *);
@@ -416,6 +417,14 @@ void PCHStmtWriter::VisitMemberExpr(MemberExpr *E) {
Code = pch::EXPR_MEMBER;
}
+void PCHStmtWriter::VisitObjCIsaExpr(ObjCIsaExpr *E) {
+ VisitExpr(E);
+ Writer.WriteSubStmt(E->getBase());
+ Writer.AddSourceLocation(E->getIsaMemberLoc(), Record);
+ Record.push_back(E->isArrow());
+ Code = pch::EXPR_OBJC_ISA;
+}
+
void PCHStmtWriter::VisitCastExpr(CastExpr *E) {
VisitExpr(E);
Writer.WriteSubStmt(E->getSubExpr());
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index bfde991555a..66e73f99e90 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -2283,7 +2283,6 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
const ObjCObjectPointerType *OPT = BaseType->getAsObjCObjectPointerType();
const ObjCInterfaceType *IFaceT =
OPT ? OPT->getInterfaceType() : BaseType->getAsObjCInterfaceType();
-
if (IFaceT) {
ObjCInterfaceDecl *IDecl = IFaceT->getDecl();
ObjCInterfaceDecl *ClassDeclared;
@@ -2340,7 +2339,11 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
<< IDecl->getDeclName() << &Member
<< BaseExpr->getSourceRange());
}
- // We don't have an interface. FIXME: deal with ObjC builtin 'id' type.
+ // We have an 'id' type. Rather than fall through, we check if this
+ // is a reference to 'isa'.
+ if (&Member == &Context.Idents.get("isa"))
+ return Owned(new (Context) ObjCIsaExpr(BaseExpr, true, MemberLoc,
+ Context.getObjCIdType()));
}
// Handle properties on 'id' and qualified "id".
if (OpKind == tok::period && (BaseType->isObjCIdType() ||
@@ -2472,6 +2475,13 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
<< &Member << BaseType);
}
+ // Handle the following exceptional case (*Obj).isa.
+ if (OpKind == tok::period &&
+ BaseType->isSpecificBuiltinType(BuiltinType::ObjCId) &&
+ &Member == &Context.Idents.get("isa"))
+ return Owned(new (Context) ObjCIsaExpr(BaseExpr, false, MemberLoc,
+ Context.getObjCIdType()));
+
// Handle 'field access' to vectors, such as 'V.xx'.
if (BaseType->isExtVectorType()) {
QualType ret = CheckExtVectorComponent(BaseType, OpLoc, Member, MemberLoc);
diff --git a/clang/lib/Sema/SemaTemplateInstantiateExpr.cpp b/clang/lib/Sema/SemaTemplateInstantiateExpr.cpp
index 5e664add5cb..dcf2ebcd2ee 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateExpr.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateExpr.cpp
@@ -1341,6 +1341,12 @@ TemplateExprInstantiator::VisitObjCSuperExpr(ObjCSuperExpr *E) {
}
Sema::OwningExprResult
+TemplateExprInstantiator::VisitObjCIsaExpr(ObjCIsaExpr *E) {
+ assert(false && "FIXME: Template instantiations for ObjC expressions");
+ return SemaRef.ExprError();
+}
+
+Sema::OwningExprResult
Sema::InstantiateExpr(Expr *E, const TemplateArgumentList &TemplateArgs) {
if (!E)
return Owned((Expr *)0);
OpenPOWER on IntegriCloud