From dd8079c54b0030152c373541f6b0d3d7983ef18c Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Mon, 5 Dec 2011 19:50:04 +0000 Subject: [PATCH] More objc rewriter refactoring. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145841 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Rewrite/RewriteObjC.cpp | 88 +++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 48 deletions(-) diff --git a/lib/Rewrite/RewriteObjC.cpp b/lib/Rewrite/RewriteObjC.cpp index bb9df3435f..36b8db9734 100644 --- a/lib/Rewrite/RewriteObjC.cpp +++ b/lib/Rewrite/RewriteObjC.cpp @@ -54,13 +54,10 @@ namespace { BLOCK_HAS_DESCRIPTOR = (1 << 29) }; static const int OBJC_ABI_VERSION = 7; - + Rewriter Rewrite; DiagnosticsEngine &Diags; const LangOptions &LangOpts; - unsigned RewriteFailedDiag; - unsigned TryFinallyContainsReturnDiag; - ASTContext *Context; SourceManager *SM; TranslationUnitDecl *TUDecl; @@ -68,24 +65,27 @@ namespace { const char *MainFileStart, *MainFileEnd; Stmt *CurrentBody; ParentMap *PropParentMap; // created lazily. - - SourceLocation LastIncLoc; - - SmallVector ClassImplementation; - SmallVector CategoryImplementation; - llvm::SmallPtrSet ObjCSynthesizedStructs; - llvm::SmallPtrSet ObjCSynthesizedProtocols; - llvm::SmallPtrSet ObjCForwardDecls; - llvm::DenseMap MethodInternalNames; - SmallVector Stmts; - SmallVector ObjCBcLabelNo; - // Remember all the @protocol() expressions. - llvm::SmallPtrSet ProtocolExprDecls; - - llvm::DenseSet CopyDestroyCache; + std::string InFileName; + raw_ostream* OutFile; + std::string Preamble; + TypeDecl *ProtocolTypeDecl; + VarDecl *GlobalVarDecl; + unsigned RewriteFailedDiag; + unsigned TryFinallyContainsReturnDiag; + // ObjC string constant support. unsigned NumObjCStringLiterals; + VarDecl *ConstantStringClassReference; + RecordDecl *NSStringRecord; + // ObjC foreach break/continue generation support. + int BcLabelCount; + + // Needed for super. + ObjCMethodDecl *CurMethodDef; + RecordDecl *SuperStructDecl; + RecordDecl *ConstantStringDecl; + FunctionDecl *MsgSendFunctionDecl; FunctionDecl *MsgSendSuperFunctionDecl; FunctionDecl *MsgSendStretFunctionDecl; @@ -97,32 +97,22 @@ namespace { FunctionDecl *SelGetUidFunctionDecl; FunctionDecl *CFStringFunctionDecl; FunctionDecl *SuperContructorFunctionDecl; + FunctionDecl *CurFunctionDef; + FunctionDecl *CurFunctionDeclToDeclareForBlock; - // ObjC string constant support. - VarDecl *ConstantStringClassReference; - RecordDecl *NSStringRecord; - - // ObjC foreach break/continue generation support. - int BcLabelCount; - - // Needed for super. - ObjCMethodDecl *CurMethodDef; - RecordDecl *SuperStructDecl; - RecordDecl *ConstantStringDecl; - - TypeDecl *ProtocolTypeDecl; - QualType getProtocolType(); - - // Needed for header files being rewritten - bool IsHeader; - - std::string InFileName; - raw_ostream* OutFile; - - bool SilenceRewriteMacroWarning; - bool objc_impl_method; - - std::string Preamble; + /* Misc. containers needed for meta-data rewrite. */ + SmallVector ClassImplementation; + SmallVector CategoryImplementation; + llvm::SmallPtrSet ObjCSynthesizedStructs; + llvm::SmallPtrSet ObjCSynthesizedProtocols; + llvm::SmallPtrSet ObjCForwardDecls; + llvm::DenseMap MethodInternalNames; + SmallVector Stmts; + SmallVector ObjCBcLabelNo; + // Remember all the @protocol() expressions. + llvm::SmallPtrSet ProtocolExprDecls; + + llvm::DenseSet CopyDestroyCache; // Block expressions. SmallVector Blocks; @@ -147,10 +137,11 @@ namespace { // This is needed to support some of the exotic property rewriting. llvm::DenseMap ReplacedNodes; - FunctionDecl *CurFunctionDef; - FunctionDecl *CurFunctionDeclToDeclareForBlock; - VarDecl *GlobalVarDecl; - + // Needed for header files being rewritten + bool IsHeader; + bool SilenceRewriteMacroWarning; + bool objc_impl_method; + bool DisableReplaceStmt; class DisableReplaceStmtScope { RewriteObjC &R; @@ -392,6 +383,7 @@ namespace { const SmallVector &InnerBlockDeclRefs); // Misc. helper routines. + QualType getProtocolType(); void WarnAboutReturnGotoStmts(Stmt *S); void HasReturnStmts(Stmt *S, bool &hasReturns); void CheckFunctionPointerDecl(QualType dType, NamedDecl *ND); -- 2.50.1