diff options
author | Chris Lattner <sabre@nondot.org> | 2009-04-22 05:57:30 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-04-22 05:57:30 +0000 |
commit | 19cea4eeb4b4e8dc7da3cef28d08051297001657 (patch) | |
tree | a2d4f707a89e67095e40ff1acb2da2168ca0762f /clang/lib | |
parent | 01146a5fa9ba8fa2d394437504861dd4d5f5f216 (diff) | |
download | bcm5719-llvm-19cea4eeb4b4e8dc7da3cef28d08051297001657.tar.gz bcm5719-llvm-19cea4eeb4b4e8dc7da3cef28d08051297001657.zip |
implement serialization support for @encode,
fix a couple of bugs in reader support for ObjCInterfaceDecl,
and add support for reading ObjCInterfaceType.
llvm-svn: 69779
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Frontend/PCHReader.cpp | 24 | ||||
-rw-r--r-- | clang/lib/Frontend/PCHWriter.cpp | 18 |
2 files changed, 38 insertions, 4 deletions
diff --git a/clang/lib/Frontend/PCHReader.cpp b/clang/lib/Frontend/PCHReader.cpp index 7018b26c276..e3413cbcd1d 100644 --- a/clang/lib/Frontend/PCHReader.cpp +++ b/clang/lib/Frontend/PCHReader.cpp @@ -225,7 +225,8 @@ void PCHDeclReader::VisitObjCContainerDecl(ObjCContainerDecl *CD) { void PCHDeclReader::VisitObjCInterfaceDecl(ObjCInterfaceDecl *ID) { VisitObjCContainerDecl(ID); ID->setTypeForDecl(Reader.GetType(Record[Idx++]).getTypePtr()); - ID->setSuperClass(cast<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++]))); + ID->setSuperClass(cast_or_null<ObjCInterfaceDecl> + (Reader.GetDecl(Record[Idx++]))); unsigned NumIvars = Record[Idx++]; llvm::SmallVector<ObjCIvarDecl *, 16> IVars; IVars.reserve(NumIvars); @@ -237,6 +238,7 @@ void PCHDeclReader::VisitObjCInterfaceDecl(ObjCInterfaceDecl *ID) { ID->setImplicitInterfaceDecl(Record[Idx++]); ID->setClassLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); ID->setSuperClassLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + ID->setAtEndLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); // FIXME: add protocols, categories. } @@ -464,6 +466,7 @@ namespace { unsigned VisitShuffleVectorExpr(ShuffleVectorExpr *E); unsigned VisitBlockExpr(BlockExpr *E); unsigned VisitBlockDeclRefExpr(BlockDeclRefExpr *E); + unsigned VisitObjCEncodeExpr(ObjCEncodeExpr *E); }; } @@ -1013,6 +1016,15 @@ unsigned PCHStmtReader::VisitBlockDeclRefExpr(BlockDeclRefExpr *E) { return 0; } +unsigned PCHStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) { + VisitExpr(E); + E->setEncodedType(Reader.GetType(Record[Idx++])); + E->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + return 0; +} + + //===----------------------------------------------------------------------===// // PCH reader implementation //===----------------------------------------------------------------------===// @@ -2040,9 +2052,9 @@ QualType PCHReader::ReadTypeRecord(uint64_t Offset) { return Context.getTypeDeclType(cast<EnumDecl>(GetDecl(Record[0]))); case pch::TYPE_OBJC_INTERFACE: - // FIXME: Deserialize ObjCInterfaceType - assert(false && "Cannot de-serialize ObjC interface types yet"); - return QualType(); + assert(Record.size() == 1 && "Incorrect encoding of objc interface type"); + return Context.getObjCInterfaceType( + cast<ObjCInterfaceDecl>(GetDecl(Record[0]))); case pch::TYPE_OBJC_QUALIFIED_INTERFACE: // FIXME: Deserialize ObjCQualifiedInterfaceType @@ -2933,6 +2945,10 @@ Stmt *PCHReader::ReadStmt() { case pch::EXPR_BLOCK_DECL_REF: S = new (Context) BlockDeclRefExpr(Empty); break; + + case pch::EXPR_OBJC_ENCODE: + S = new (Context) ObjCEncodeExpr(Empty); + break; } // We hit a STMT_STOP, so we're done with this expression. diff --git a/clang/lib/Frontend/PCHWriter.cpp b/clang/lib/Frontend/PCHWriter.cpp index bdcd3593142..a908a8bfeea 100644 --- a/clang/lib/Frontend/PCHWriter.cpp +++ b/clang/lib/Frontend/PCHWriter.cpp @@ -656,6 +656,11 @@ namespace { void VisitShuffleVectorExpr(ShuffleVectorExpr *E); void VisitBlockExpr(BlockExpr *E); void VisitBlockDeclRefExpr(BlockDeclRefExpr *E); + + // Objective-C + void VisitObjCEncodeExpr(ObjCEncodeExpr *E); + + }; } @@ -1148,6 +1153,19 @@ void PCHStmtWriter::VisitBlockDeclRefExpr(BlockDeclRefExpr *E) { } //===----------------------------------------------------------------------===// +// Objective-C Expressions and Statements. +//===----------------------------------------------------------------------===// + +void PCHStmtWriter::VisitObjCEncodeExpr(ObjCEncodeExpr *E) { + VisitExpr(E); + Writer.AddTypeRef(E->getEncodedType(), Record); + Writer.AddSourceLocation(E->getAtLoc(), Record); + Writer.AddSourceLocation(E->getRParenLoc(), Record); + Code = pch::EXPR_OBJC_ENCODE; +} + + +//===----------------------------------------------------------------------===// // PCHWriter Implementation //===----------------------------------------------------------------------===// |