diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/DeclObjC.cpp | 10 | ||||
-rw-r--r-- | clang/lib/Frontend/PCHReader.cpp | 31 | ||||
-rw-r--r-- | clang/lib/Frontend/PCHWriter.cpp | 27 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 8 |
4 files changed, 67 insertions, 9 deletions
diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp index 4a3c4d4f30e..9cc22912caf 100644 --- a/clang/lib/AST/DeclObjC.cpp +++ b/clang/lib/AST/DeclObjC.cpp @@ -285,12 +285,12 @@ void ObjCMethodDecl::createImplicitParams(ASTContext &Context, } else // we have a factory method. selfTy = Context.getObjCClassType(); - SelfDecl = ImplicitParamDecl::Create(Context, this, SourceLocation(), - &Context.Idents.get("self"), selfTy); + setSelfDecl(ImplicitParamDecl::Create(Context, this, SourceLocation(), + &Context.Idents.get("self"), selfTy)); - CmdDecl = ImplicitParamDecl::Create(Context, this, SourceLocation(), - &Context.Idents.get("_cmd"), - Context.getObjCSelType()); + setCmdDecl(ImplicitParamDecl::Create(Context, this, SourceLocation(), + &Context.Idents.get("_cmd"), + Context.getObjCSelType())); } diff --git a/clang/lib/Frontend/PCHReader.cpp b/clang/lib/Frontend/PCHReader.cpp index 9af75aef2b4..391937b9234 100644 --- a/clang/lib/Frontend/PCHReader.cpp +++ b/clang/lib/Frontend/PCHReader.cpp @@ -67,6 +67,7 @@ namespace { void VisitFileScopeAsmDecl(FileScopeAsmDecl *AD); void VisitBlockDecl(BlockDecl *BD); std::pair<uint64_t, uint64_t> VisitDeclContext(DeclContext *DC); + void VisitObjCMethodDecl(ObjCMethodDecl *D); }; } @@ -159,6 +160,30 @@ void PCHDeclReader::VisitFunctionDecl(FunctionDecl *FD) { FD->setParams(Reader.getContext(), &Params[0], NumParams); } +void PCHDeclReader::VisitObjCMethodDecl(ObjCMethodDecl *MD) { + VisitNamedDecl(MD); + if (Record[Idx++]) { + // In practice, this won't be executed (since method definitions + // don't occur in header files). + MD->setBody(cast<CompoundStmt>(Reader.GetStmt(Record[Idx++]))); + MD->setSelfDecl(cast<ImplicitParamDecl>(Reader.GetDecl(Record[Idx++]))); + MD->setCmdDecl(cast<ImplicitParamDecl>(Reader.GetDecl(Record[Idx++]))); + } + MD->setInstanceMethod(Record[Idx++]); + MD->setVariadic(Record[Idx++]); + MD->setSynthesized(Record[Idx++]); + MD->setDeclImplementation((ObjCMethodDecl::ImplementationControl)Record[Idx++]); + MD->setObjCDeclQualifier((Decl::ObjCDeclQualifier)Record[Idx++]); + MD->setResultType(Reader.GetType(Record[Idx++])); + MD->setEndLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + unsigned NumParams = Record[Idx++]; + llvm::SmallVector<ParmVarDecl *, 16> Params; + Params.reserve(NumParams); + for (unsigned I = 0; I != NumParams; ++I) + Params.push_back(cast<ParmVarDecl>(Reader.GetDecl(Record[Idx++]))); + MD->setMethodParams(Reader.getContext(), &Params[0], NumParams); +} + void PCHDeclReader::VisitFieldDecl(FieldDecl *FD) { VisitValueDecl(FD); FD->setMutable(Record[Idx++]); @@ -1770,6 +1795,12 @@ Decl *PCHReader::ReadDeclRecord(uint64_t Offset, unsigned Index) { break; } + case pch::DECL_OBJC_METHOD: { + D = ObjCMethodDecl::Create(Context, SourceLocation(), SourceLocation(), + Selector(), QualType(), 0); + break; + } + case pch::DECL_FIELD: { D = FieldDecl::Create(Context, 0, SourceLocation(), 0, QualType(), 0, false); diff --git a/clang/lib/Frontend/PCHWriter.cpp b/clang/lib/Frontend/PCHWriter.cpp index 9f22f13134b..6aea7a53727 100644 --- a/clang/lib/Frontend/PCHWriter.cpp +++ b/clang/lib/Frontend/PCHWriter.cpp @@ -270,6 +270,7 @@ namespace { void VisitBlockDecl(BlockDecl *D); void VisitDeclContext(DeclContext *DC, uint64_t LexicalOffset, uint64_t VisibleOffset); + void VisitObjCMethodDecl(ObjCMethodDecl *D); }; } @@ -359,6 +360,32 @@ void PCHDeclWriter::VisitFunctionDecl(FunctionDecl *D) { Code = pch::DECL_FUNCTION; } +void PCHDeclWriter::VisitObjCMethodDecl(ObjCMethodDecl *D) { + VisitNamedDecl(D); + // FIXME: convert to LazyStmtPtr? + // Unlike C/C++, method bodies will never be in header files. + Record.push_back(D->getBody() != 0); + if (D->getBody() != 0) { + Writer.AddStmt(D->getBody(Context)); + Writer.AddDeclRef(D->getSelfDecl(), Record); + Writer.AddDeclRef(D->getCmdDecl(), Record); + } + Record.push_back(D->isInstanceMethod()); + Record.push_back(D->isVariadic()); + Record.push_back(D->isSynthesized()); + // FIXME: stable encoding for @required/@optional + Record.push_back(D->getImplementationControl()); + // FIXME: stable encoding for in/out/inout/bycopy/byref/oneway + Record.push_back(D->getObjCDeclQualifier()); + Writer.AddTypeRef(D->getResultType(), Record); + Writer.AddSourceLocation(D->getLocEnd(), Record); + Record.push_back(D->param_size()); + for (ObjCMethodDecl::param_iterator P = D->param_begin(), + PEnd = D->param_end(); P != PEnd; ++P) + Writer.AddDeclRef(*P, Record); + Code = pch::DECL_OBJC_METHOD; +} + void PCHDeclWriter::VisitFieldDecl(FieldDecl *D) { VisitValueDecl(D); Record.push_back(D->isMutable()); diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index db81cacc2b6..b813e085eea 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -1226,7 +1226,7 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property, } else // A user declared getter will be synthesize when @synthesize of // the property with the same name is seen in the @implementation - GetterMethod->setIsSynthesized(); + GetterMethod->setSynthesized(true); property->setGetterMethodDecl(GetterMethod); // Skip setter if property is read-only. @@ -1252,12 +1252,12 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property, property->getType(), VarDecl::None, 0); - SetterMethod->setMethodParams(&Argument, 1, Context); + SetterMethod->setMethodParams(Context, &Argument, 1); CD->addDecl(Context, SetterMethod); } else // A user declared setter will be synthesize when @synthesize of // the property with the same name is seen in the @implementation - SetterMethod->setIsSynthesized(); + SetterMethod->setSynthesized(true); property->setSetterMethodDecl(SetterMethod); } // Add any synthesized methods to the global pool. This allows us to @@ -1506,7 +1506,7 @@ Sema::DeclPtrTy Sema::ActOnMethodDeclaration( Params.push_back(Param); } - ObjCMethod->setMethodParams(&Params[0], Sel.getNumArgs(), Context); + ObjCMethod->setMethodParams(Context, &Params[0], Sel.getNumArgs()); ObjCMethod->setObjCDeclQualifier( CvtQTToAstBitMask(ReturnQT.getObjCDeclQualifier())); const ObjCMethodDecl *PrevMethod = 0; |