diff options
author | dim <dim@FreeBSD.org> | 2014-03-21 17:53:59 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2014-03-21 17:53:59 +0000 |
commit | 9cedb8bb69b89b0f0c529937247a6a80cabdbaec (patch) | |
tree | c978f0e9ec1ab92dc8123783f30b08a7fd1e2a39 /contrib/llvm/tools/clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp | |
parent | 03fdc2934eb61c44c049a02b02aa974cfdd8a0eb (diff) | |
download | FreeBSD-src-9cedb8bb69b89b0f0c529937247a6a80cabdbaec.zip FreeBSD-src-9cedb8bb69b89b0f0c529937247a6a80cabdbaec.tar.gz |
MFC 261991:
Upgrade our copy of llvm/clang to 3.4 release. This version supports
all of the features in the current working draft of the upcoming C++
standard, provisionally named C++1y.
The code generator's performance is greatly increased, and the loop
auto-vectorizer is now enabled at -Os and -O2 in addition to -O3. The
PowerPC backend has made several major improvements to code generation
quality and compile time, and the X86, SPARC, ARM32, Aarch64 and SystemZ
backends have all seen major feature work.
Release notes for llvm and clang can be found here:
<http://llvm.org/releases/3.4/docs/ReleaseNotes.html>
<http://llvm.org/releases/3.4/tools/clang/docs/ReleaseNotes.html>
MFC 262121 (by emaste):
Update lldb for clang/llvm 3.4 import
This commit largely restores the lldb source to the upstream r196259
snapshot with the addition of threaded inferior support and a few bug
fixes.
Specific upstream lldb revisions restored include:
SVN git
181387 779e6ac
181703 7bef4e2
182099 b31044e
182650 f2dcf35
182683 0d91b80
183862 15c1774
183929 99447a6
184177 0b2934b
184948 4dc3761
184954 007e7bc
186990 eebd175
Sponsored by: DARPA, AFRL
MFC 262186 (by emaste):
Fix mismerge in r262121
A break statement was lost in the merge. The error had no functional
impact, but restore it to reduce the diff against upstream.
MFC 262303:
Pull in r197521 from upstream clang trunk (by rdivacky):
Use the integrated assembler by default on FreeBSD/ppc and ppc64.
Requested by: jhibbits
MFC 262611:
Pull in r196874 from upstream llvm trunk:
Fix a crash that occurs when PWD is invalid.
MCJIT needs to be able to run in hostile environments, even when PWD
is invalid. There's no need to crash MCJIT in this case.
The obvious fix is to simply leave MCContext's CompilationDir empty
when PWD can't be determined. This way, MCJIT clients,
and other clients that link with LLVM don't need a valid working directory.
If we do want to guarantee valid CompilationDir, that should be done
only for clients of getCompilationDir(). This is as simple as checking
for an empty string.
The only current use of getCompilationDir is EmitGenDwarfInfo, which
won't conceivably run with an invalid working dir. However, in the
purely hypothetically and untestable case that this happens, the
AT_comp_dir will be omitted from the compilation_unit DIE.
This should help fix assertions occurring with ports-mgmt/tinderbox,
when it is using jails, and sometimes invalidates clang's current
working directory.
Reported by: decke
MFC 262809:
Pull in r203007 from upstream clang trunk:
Don't produce an alias between destructors with different calling conventions.
Fixes pr19007.
(Please note that is an LLVM PR identifier, not a FreeBSD one.)
This should fix Firefox and/or libxul crashes (due to problems with
regparm/stdcall calling conventions) on i386.
Reported by: multiple users on freebsd-current
PR: bin/187103
MFC 263048:
Repair recognition of "CC" as an alias for the C++ compiler, since it
was silently broken by upstream for a Windows-specific use-case.
Apparently some versions of CMake still rely on this archaic feature...
Reported by: rakuco
MFC 263049:
Garbage collect the old way of adding the libstdc++ include directories
in clang's InitHeaderSearch.cpp. This has been superseded by David
Chisnall's commit in r255321.
Moreover, if libc++ is used, the libstdc++ include directories should
not be in the search path at all. These directories are now only used
if you pass -stdlib=libstdc++.
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp')
-rw-r--r-- | contrib/llvm/tools/clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp | 208 |
1 files changed, 110 insertions, 98 deletions
diff --git a/contrib/llvm/tools/clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp b/contrib/llvm/tools/clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp index 0e59b11..ae33ac8 100644 --- a/contrib/llvm/tools/clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp +++ b/contrib/llvm/tools/clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp @@ -58,7 +58,6 @@ namespace { BLOCK_IS_GLOBAL = (1 << 28), BLOCK_HAS_DESCRIPTOR = (1 << 29) }; - static const int OBJC_ABI_VERSION = 7; Rewriter Rewrite; DiagnosticsEngine &Diags; @@ -103,7 +102,7 @@ namespace { FunctionDecl *GetSuperClassFunctionDecl; FunctionDecl *SelGetUidFunctionDecl; FunctionDecl *CFStringFunctionDecl; - FunctionDecl *SuperContructorFunctionDecl; + FunctionDecl *SuperConstructorFunctionDecl; FunctionDecl *CurFunctionDef; /* Misc. containers needed for meta-data rewrite. */ @@ -222,6 +221,21 @@ namespace { } return true; } + + virtual void HandleTopLevelDeclInObjCContainer(DeclGroupRef D) { + for (DeclGroupRef::iterator I = D.begin(), E = D.end(); I != E; ++I) { + if (TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(*I)) { + if (isTopLevelBlockPointerType(TD->getUnderlyingType())) + RewriteBlockPointerDecl(TD); + else if (TD->getUnderlyingType()->isFunctionPointerType()) + CheckFunctionPointerDecl(TD->getUnderlyingType(), TD); + else + RewriteObjCQualifiedInterfaceTypes(TD); + } + } + return; + } + void HandleTopLevelSingleDecl(Decl *D); void HandleDeclInMainFile(Decl *D); RewriteModernObjC(std::string inFile, raw_ostream *OS, @@ -307,7 +321,7 @@ namespace { void ConvertSourceLocationToLineDirective(SourceLocation Loc, std::string &LineString); void RewriteForwardClassDecl(DeclGroupRef D); - void RewriteForwardClassDecl(const SmallVector<Decl *, 8> &DG); + void RewriteForwardClassDecl(const SmallVectorImpl<Decl *> &DG); void RewriteForwardClassEpilogue(ObjCInterfaceDecl *ClassDecl, const std::string &typedefString); void RewriteImplementations(); @@ -325,7 +339,7 @@ namespace { void RewriteCategoryDecl(ObjCCategoryDecl *Dcl); void RewriteProtocolDecl(ObjCProtocolDecl *Dcl); void RewriteForwardProtocolDecl(DeclGroupRef D); - void RewriteForwardProtocolDecl(const SmallVector<Decl *, 8> &DG); + void RewriteForwardProtocolDecl(const SmallVectorImpl<Decl *> &DG); void RewriteMethodDeclaration(ObjCMethodDecl *Method); void RewriteProperty(ObjCPropertyDecl *prop); void RewriteFunctionDecl(FunctionDecl *FD); @@ -411,7 +425,6 @@ namespace { SourceLocation EndLoc=SourceLocation()); Expr *SynthMsgSendStretCallExpr(FunctionDecl *MsgSendStretFlavor, - QualType msgSendType, QualType returnType, SmallVectorImpl<QualType> &ArgTypes, SmallVectorImpl<Expr*> &MsgExprs, @@ -431,7 +444,7 @@ namespace { void SynthGetMetaClassFunctionDecl(); void SynthGetSuperClassFunctionDecl(); void SynthSelGetUidFunctionDecl(); - void SynthSuperContructorFunctionDecl(); + void SynthSuperConstructorFunctionDecl(); // Rewriting metadata template<typename MethodIterator> @@ -478,7 +491,7 @@ namespace { StringRef FunName); FunctionDecl *SynthBlockInitFunctionDecl(StringRef name); Stmt *SynthBlockInitExpr(BlockExpr *Exp, - const SmallVector<DeclRefExpr *, 8> &InnerBlockDeclRefs); + const SmallVectorImpl<DeclRefExpr *> &InnerBlockDeclRefs); // Misc. helper routines. QualType getProtocolType(); @@ -490,8 +503,8 @@ namespace { bool IsDeclStmtInForeachHeader(DeclStmt *DS); void CollectBlockDeclRefInfo(BlockExpr *Exp); void GetBlockDeclRefExprs(Stmt *S); - void GetInnerBlockDeclRefExprs(Stmt *S, - SmallVector<DeclRefExpr *, 8> &InnerBlockDeclRefs, + void GetInnerBlockDeclRefExprs(Stmt *S, + SmallVectorImpl<DeclRefExpr *> &InnerBlockDeclRefs, llvm::SmallPtrSet<const DeclContext *, 8> &InnerContexts); // We avoid calling Type::isBlockPointerType(), since it operates on the @@ -686,7 +699,7 @@ void RewriteModernObjC::InitializeCommon(ASTContext &context) { ProtocolTypeDecl = 0; ConstantStringDecl = 0; BcLabelCount = 0; - SuperContructorFunctionDecl = 0; + SuperConstructorFunctionDecl = 0; NumObjCStringLiterals = 0; PropParentMap = 0; CurrentBody = 0; @@ -791,7 +804,7 @@ void RewriteModernObjC::HandleTopLevelSingleDecl(Decl *D) { } } // If we have a decl in the main file, see if we should rewrite it. - if (SM->isFromMainFile(Loc)) + if (SM->isWrittenInMainFile(Loc)) return HandleDeclInMainFile(D); } @@ -1068,23 +1081,26 @@ void RewriteModernObjC::RewriteForwardClassEpilogue(ObjCInterfaceDecl *ClassDecl void RewriteModernObjC::RewriteForwardClassDecl(DeclGroupRef D) { std::string typedefString; for (DeclGroupRef::iterator I = D.begin(), E = D.end(); I != E; ++I) { - ObjCInterfaceDecl *ForwardDecl = cast<ObjCInterfaceDecl>(*I); - if (I == D.begin()) { - // Translate to typedef's that forward reference structs with the same name - // as the class. As a convenience, we include the original declaration - // as a comment. - typedefString += "// @class "; - typedefString += ForwardDecl->getNameAsString(); - typedefString += ";"; + if (ObjCInterfaceDecl *ForwardDecl = dyn_cast<ObjCInterfaceDecl>(*I)) { + if (I == D.begin()) { + // Translate to typedef's that forward reference structs with the same name + // as the class. As a convenience, we include the original declaration + // as a comment. + typedefString += "// @class "; + typedefString += ForwardDecl->getNameAsString(); + typedefString += ";"; + } + RewriteOneForwardClassDecl(ForwardDecl, typedefString); } - RewriteOneForwardClassDecl(ForwardDecl, typedefString); + else + HandleTopLevelSingleDecl(*I); } DeclGroupRef::iterator I = D.begin(); RewriteForwardClassEpilogue(cast<ObjCInterfaceDecl>(*I), typedefString); } void RewriteModernObjC::RewriteForwardClassDecl( - const SmallVector<Decl *, 8> &D) { + const SmallVectorImpl<Decl *> &D) { std::string typedefString; for (unsigned i = 0; i < D.size(); i++) { ObjCInterfaceDecl *ForwardDecl = cast<ObjCInterfaceDecl>(D[i]); @@ -1202,7 +1218,7 @@ void RewriteModernObjC::RewriteForwardProtocolDecl(DeclGroupRef D) { } void -RewriteModernObjC::RewriteForwardProtocolDecl(const SmallVector<Decl *, 8> &DG) { +RewriteModernObjC::RewriteForwardProtocolDecl(const SmallVectorImpl<Decl *> &DG) { SourceLocation LocStart = DG[0]->getLocStart(); if (LocStart.isInvalid()) llvm_unreachable("Invalid SourceLocation"); @@ -1618,23 +1634,23 @@ Stmt *RewriteModernObjC::RewritePropertyOrImplicitGetter(PseudoObjectExpr *Pseud } /// SynthCountByEnumWithState - To print: -/// ((unsigned int (*) -/// (id, SEL, struct __objcFastEnumerationState *, id *, unsigned int)) +/// ((NSUInteger (*) +/// (id, SEL, struct __objcFastEnumerationState *, id *, NSUInteger)) /// (void *)objc_msgSend)((id)l_collection, /// sel_registerName( /// "countByEnumeratingWithState:objects:count:"), /// &enumState, -/// (id *)__rw_items, (unsigned int)16) +/// (id *)__rw_items, (NSUInteger)16) /// void RewriteModernObjC::SynthCountByEnumWithState(std::string &buf) { - buf += "((unsigned int (*) (id, SEL, struct __objcFastEnumerationState *, " - "id *, unsigned int))(void *)objc_msgSend)"; + buf += "((_WIN_NSUInteger (*) (id, SEL, struct __objcFastEnumerationState *, " + "id *, _WIN_NSUInteger))(void *)objc_msgSend)"; buf += "\n\t\t"; buf += "((id)l_collection,\n\t\t"; buf += "sel_registerName(\"countByEnumeratingWithState:objects:count:\"),"; buf += "\n\t\t"; buf += "&enumState, " - "(id *)__rw_items, (unsigned int)16)"; + "(id *)__rw_items, (_WIN_NSUInteger)16)"; } /// RewriteBreakStmt - Rewrite for a break-stmt inside an ObjC2's foreach @@ -1694,7 +1710,7 @@ Stmt *RewriteModernObjC::RewriteContinueStmt(ContinueStmt *S) { /// struct __objcFastEnumerationState enumState = { 0 }; /// id __rw_items[16]; /// id l_collection = (id)collection; -/// unsigned long limit = [l_collection countByEnumeratingWithState:&enumState +/// NSUInteger limit = [l_collection countByEnumeratingWithState:&enumState /// objects:__rw_items count:16]; /// if (limit) { /// unsigned long startMutations = *enumState.mutationsPtr; @@ -1707,8 +1723,8 @@ Stmt *RewriteModernObjC::RewriteContinueStmt(ContinueStmt *S) { /// stmts; /// __continue_label: ; /// } while (counter < limit); -/// } while (limit = [l_collection countByEnumeratingWithState:&enumState -/// objects:__rw_items count:16]); +/// } while ((limit = [l_collection countByEnumeratingWithState:&enumState +/// objects:__rw_items count:16])); /// elem = nil; /// __break_label: ; /// } @@ -1791,15 +1807,15 @@ Stmt *RewriteModernObjC::RewriteObjCForCollectionStmt(ObjCForCollectionStmt *S, // unsigned long limit = [l_collection countByEnumeratingWithState:&enumState // objects:__rw_items count:16]; // which is synthesized into: - // unsigned int limit = - // ((unsigned int (*) - // (id, SEL, struct __objcFastEnumerationState *, id *, unsigned int)) + // NSUInteger limit = + // ((NSUInteger (*) + // (id, SEL, struct __objcFastEnumerationState *, id *, NSUInteger)) // (void *)objc_msgSend)((id)l_collection, // sel_registerName( // "countByEnumeratingWithState:objects:count:"), // (struct __objcFastEnumerationState *)&state, - // (id *)__rw_items, (unsigned int)16); - buf += "unsigned long limit =\n\t\t"; + // (id *)__rw_items, (NSUInteger)16); + buf += "_WIN_NSUInteger limit =\n\t\t"; SynthCountByEnumWithState(buf); buf += ";\n\t"; /// if (limit) { @@ -1826,8 +1842,8 @@ Stmt *RewriteModernObjC::RewriteObjCForCollectionStmt(ObjCForCollectionStmt *S, /// __continue_label: ; /// } while (counter < limit); - /// } while (limit = [l_collection countByEnumeratingWithState:&enumState - /// objects:__rw_items count:16]); + /// } while ((limit = [l_collection countByEnumeratingWithState:&enumState + /// objects:__rw_items count:16])); /// elem = nil; /// __break_label: ; /// } @@ -1841,9 +1857,9 @@ Stmt *RewriteModernObjC::RewriteObjCForCollectionStmt(ObjCForCollectionStmt *S, buf += ": ;"; buf += "\n\t\t"; buf += "} while (counter < limit);\n\t"; - buf += "} while (limit = "; + buf += "} while ((limit = "; SynthCountByEnumWithState(buf); - buf += ");\n\t"; + buf += "));\n\t"; buf += elementName; buf += " = (("; buf += elementTypeAsString; @@ -1906,7 +1922,7 @@ Stmt *RewriteModernObjC::RewriteObjCSynchronizedStmt(ObjCAtSynchronizedStmt *S) std::string buf; SourceLocation SynchLoc = S->getAtSynchronizedLoc(); ConvertSourceLocationToLineDirective(SynchLoc, buf); - buf += "{ id _rethrow = 0; id _sync_obj = "; + buf += "{ id _rethrow = 0; id _sync_obj = (id)"; const char *lparenBuf = startBuf; while (*lparenBuf != '(') lparenBuf++; @@ -2447,9 +2463,9 @@ void RewriteModernObjC::RewriteBlockLiteralFunctionDecl(FunctionDecl *FD) { InsertText(FunLocStart, FdStr); } -// SynthSuperContructorFunctionDecl - id __rw_objc_super(id obj, id super); -void RewriteModernObjC::SynthSuperContructorFunctionDecl() { - if (SuperContructorFunctionDecl) +// SynthSuperConstructorFunctionDecl - id __rw_objc_super(id obj, id super); +void RewriteModernObjC::SynthSuperConstructorFunctionDecl() { + if (SuperConstructorFunctionDecl) return; IdentifierInfo *msgSendIdent = &Context->Idents.get("__rw_objc_super"); SmallVector<QualType, 16> ArgTys; @@ -2459,7 +2475,7 @@ void RewriteModernObjC::SynthSuperContructorFunctionDecl() { ArgTys.push_back(argT); QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(), ArgTys); - SuperContructorFunctionDecl = FunctionDecl::Create(*Context, TUDecl, + SuperConstructorFunctionDecl = FunctionDecl::Create(*Context, TUDecl, SourceLocation(), SourceLocation(), msgSendIdent, msgSendType, @@ -3183,7 +3199,6 @@ void RewriteModernObjC::RewriteLineDirective(const Decl *D) { /// starting with receiver. /// Method - Method being rewritten. Expr *RewriteModernObjC::SynthMsgSendStretCallExpr(FunctionDecl *MsgSendStretFlavor, - QualType msgSendType, QualType returnType, SmallVectorImpl<QualType> &ArgTypes, SmallVectorImpl<Expr*> &MsgExprs, @@ -3199,6 +3214,7 @@ Expr *RewriteModernObjC::SynthMsgSendStretCallExpr(FunctionDecl *MsgSendStretFla std::string name = "__Stret"; name += utostr(stretCount); std::string str = "extern \"C\" void * __cdecl memset(void *_Dst, int _Val, size_t _Size);\n"; + str += "namespace {\n"; str += "struct "; str += name; str += " {\n\t"; str += name; @@ -3217,9 +3233,27 @@ Expr *RewriteModernObjC::SynthMsgSendStretCallExpr(FunctionDecl *MsgSendStretFla } str += ") {\n"; - str += "\t if (receiver == 0)\n"; + str += "\t unsigned size = sizeof("; + str += returnType.getAsString(Context->getPrintingPolicy()); str += ");\n"; + + str += "\t if (size == 1 || size == 2 || size == 4 || size == 8)\n"; + + str += "\t s = (("; str += castType.getAsString(Context->getPrintingPolicy()); + str += ")(void *)objc_msgSend)(receiver, sel"; + for (unsigned i = 2; i < ArgTypes.size(); i++) { + str += ", arg"; str += utostr(i); + } + // could be vararg. + for (unsigned i = ArgTypes.size(); i < MsgExprs.size(); i++) { + str += ", arg"; str += utostr(i); + } + str+= ");\n"; + + str += "\t else if (receiver == 0)\n"; str += "\t memset((void*)&s, 0, sizeof(s));\n"; str += "\t else\n"; + + str += "\t s = (("; str += castType.getAsString(Context->getPrintingPolicy()); str += ")(void *)objc_msgSend_stret)(receiver, sel"; for (unsigned i = 2; i < ArgTypes.size(); i++) { @@ -3229,12 +3263,13 @@ Expr *RewriteModernObjC::SynthMsgSendStretCallExpr(FunctionDecl *MsgSendStretFla for (unsigned i = ArgTypes.size(); i < MsgExprs.size(); i++) { str += ", arg"; str += utostr(i); } - str += ");\n"; + + str += "\t}\n"; str += "\t"; str += returnType.getAsString(Context->getPrintingPolicy()); str += " s;\n"; - str += "};\n\n"; + str += "};\n};\n\n"; SourceLocation FunLocStart; if (CurFunctionDef) FunLocStart = getFunctionSourceLocation(*this, CurFunctionDef); @@ -3357,9 +3392,9 @@ Stmt *RewriteModernObjC::SynthMessageExpr(ObjCMessageExpr *Exp, Expr *SuperRep; if (LangOpts.MicrosoftExt) { - SynthSuperContructorFunctionDecl(); - // Simulate a contructor call... - DeclRefExpr *DRE = new (Context) DeclRefExpr(SuperContructorFunctionDecl, + SynthSuperConstructorFunctionDecl(); + // Simulate a constructor call... + DeclRefExpr *DRE = new (Context) DeclRefExpr(SuperConstructorFunctionDecl, false, superType, VK_LValue, SourceLocation()); SuperRep = new (Context) CallExpr(*Context, DRE, InitExprs, @@ -3465,9 +3500,9 @@ Stmt *RewriteModernObjC::SynthMessageExpr(ObjCMessageExpr *Exp, Expr *SuperRep; if (LangOpts.MicrosoftExt) { - SynthSuperContructorFunctionDecl(); - // Simulate a contructor call... - DeclRefExpr *DRE = new (Context) DeclRefExpr(SuperContructorFunctionDecl, + SynthSuperConstructorFunctionDecl(); + // Simulate a constructor call... + DeclRefExpr *DRE = new (Context) DeclRefExpr(SuperConstructorFunctionDecl, false, superType, VK_LValue, SourceLocation()); SuperRep = new (Context) CallExpr(*Context, DRE, InitExprs, @@ -3651,39 +3686,11 @@ Stmt *RewriteModernObjC::SynthMessageExpr(ObjCMessageExpr *Exp, // expression which dictate which one to envoke depending on size of // method's return type. - Expr *STCE = SynthMsgSendStretCallExpr(MsgSendStretFlavor, - msgSendType, returnType, + Expr *STCE = SynthMsgSendStretCallExpr(MsgSendStretFlavor, + returnType, ArgTypes, MsgExprs, Exp->getMethodDecl()); - - // Build sizeof(returnType) - UnaryExprOrTypeTraitExpr *sizeofExpr = - new (Context) UnaryExprOrTypeTraitExpr(UETT_SizeOf, - Context->getTrivialTypeSourceInfo(returnType), - Context->getSizeType(), SourceLocation(), - SourceLocation()); - // (sizeof(returnType) <= 8 ? objc_msgSend(...) : objc_msgSend_stret(...)) - // FIXME: Value of 8 is base on ppc32/x86 ABI for the most common cases. - // For X86 it is more complicated and some kind of target specific routine - // is needed to decide what to do. - unsigned IntSize = - static_cast<unsigned>(Context->getTypeSize(Context->IntTy)); - IntegerLiteral *limit = IntegerLiteral::Create(*Context, - llvm::APInt(IntSize, 8), - Context->IntTy, - SourceLocation()); - BinaryOperator *lessThanExpr = - new (Context) BinaryOperator(sizeofExpr, limit, BO_LE, Context->IntTy, - VK_RValue, OK_Ordinary, SourceLocation(), - false); - // (sizeof(returnType) <= 8 ? objc_msgSend(...) : objc_msgSend_stret(...)) - ConditionalOperator *CondExpr = - new (Context) ConditionalOperator(lessThanExpr, - SourceLocation(), CE, - SourceLocation(), STCE, - returnType, VK_RValue, OK_Ordinary); - ReplacingStmt = new (Context) ParenExpr(SourceLocation(), SourceLocation(), - CondExpr); + ReplacingStmt = STCE; } // delete Exp; leak for now, see RewritePropertyOrImplicitSetter() usage for more info. return ReplacingStmt; @@ -4262,7 +4269,7 @@ std::string RewriteModernObjC::SynthesizeBlockFunc(BlockExpr *CE, int i, // Create local declarations to avoid rewriting all closure decl ref exprs. // First, emit a declaration for all "by ref" decls. - for (SmallVector<ValueDecl*,8>::iterator I = BlockByRefDecls.begin(), + for (SmallVectorImpl<ValueDecl *>::iterator I = BlockByRefDecls.begin(), E = BlockByRefDecls.end(); I != E; ++I) { S += " "; std::string Name = (*I)->getNameAsString(); @@ -4273,7 +4280,7 @@ std::string RewriteModernObjC::SynthesizeBlockFunc(BlockExpr *CE, int i, S += Name + " = __cself->" + (*I)->getNameAsString() + "; // bound by ref\n"; } // Next, emit a declaration for all "by copy" declarations. - for (SmallVector<ValueDecl*,8>::iterator I = BlockByCopyDecls.begin(), + for (SmallVectorImpl<ValueDecl *>::iterator I = BlockByCopyDecls.begin(), E = BlockByCopyDecls.end(); I != E; ++I) { S += " "; // Handle nested closure invocation. For example: @@ -4374,7 +4381,7 @@ std::string RewriteModernObjC::SynthesizeBlockImpl(BlockExpr *CE, std::string Ta if (BlockDeclRefs.size()) { // Output all "by copy" declarations. - for (SmallVector<ValueDecl*,8>::iterator I = BlockByCopyDecls.begin(), + for (SmallVectorImpl<ValueDecl *>::iterator I = BlockByCopyDecls.begin(), E = BlockByCopyDecls.end(); I != E; ++I) { S += " "; std::string FieldName = (*I)->getNameAsString(); @@ -4403,7 +4410,7 @@ std::string RewriteModernObjC::SynthesizeBlockImpl(BlockExpr *CE, std::string Ta S += FieldName + ";\n"; } // Output all "by ref" declarations. - for (SmallVector<ValueDecl*,8>::iterator I = BlockByRefDecls.begin(), + for (SmallVectorImpl<ValueDecl *>::iterator I = BlockByRefDecls.begin(), E = BlockByRefDecls.end(); I != E; ++I) { S += " "; std::string FieldName = (*I)->getNameAsString(); @@ -4422,7 +4429,7 @@ std::string RewriteModernObjC::SynthesizeBlockImpl(BlockExpr *CE, std::string Ta Constructor += ", int flags=0)"; // Initialize all "by copy" arguments. bool firsTime = true; - for (SmallVector<ValueDecl*,8>::iterator I = BlockByCopyDecls.begin(), + for (SmallVectorImpl<ValueDecl *>::iterator I = BlockByCopyDecls.begin(), E = BlockByCopyDecls.end(); I != E; ++I) { std::string Name = (*I)->getNameAsString(); if (firsTime) { @@ -4437,7 +4444,7 @@ std::string RewriteModernObjC::SynthesizeBlockImpl(BlockExpr *CE, std::string Ta Constructor += Name + "(_" + Name + ")"; } // Initialize all "by ref" arguments. - for (SmallVector<ValueDecl*,8>::iterator I = BlockByRefDecls.begin(), + for (SmallVectorImpl<ValueDecl *>::iterator I = BlockByRefDecls.begin(), E = BlockByRefDecls.end(); I != E; ++I) { std::string Name = (*I)->getNameAsString(); if (firsTime) { @@ -4662,8 +4669,8 @@ void RewriteModernObjC::GetBlockDeclRefExprs(Stmt *S) { return; } -void RewriteModernObjC::GetInnerBlockDeclRefExprs(Stmt *S, - SmallVector<DeclRefExpr *, 8> &InnerBlockDeclRefs, +void RewriteModernObjC::GetInnerBlockDeclRefExprs(Stmt *S, + SmallVectorImpl<DeclRefExpr *> &InnerBlockDeclRefs, llvm::SmallPtrSet<const DeclContext *, 8> &InnerContexts) { for (Stmt::child_range CI = S->children(); CI; ++CI) if (*CI) { @@ -5407,7 +5414,7 @@ FunctionDecl *RewriteModernObjC::SynthBlockInitFunctionDecl(StringRef name) { } Stmt *RewriteModernObjC::SynthBlockInitExpr(BlockExpr *Exp, - const SmallVector<DeclRefExpr *, 8> &InnerBlockDeclRefs) { + const SmallVectorImpl<DeclRefExpr *> &InnerBlockDeclRefs) { const BlockDecl *block = Exp->getBlockDecl(); @@ -5474,7 +5481,7 @@ Stmt *RewriteModernObjC::SynthBlockInitExpr(BlockExpr *Exp, FunctionDecl *FD; Expr *NewRep; - // Simulate a contructor call... + // Simulate a constructor call... std::string Tag; if (GlobalBlockExpr) @@ -5520,7 +5527,7 @@ Stmt *RewriteModernObjC::SynthBlockInitExpr(BlockExpr *Exp, if (BlockDeclRefs.size()) { Expr *Exp; // Output all "by copy" declarations. - for (SmallVector<ValueDecl*,8>::iterator I = BlockByCopyDecls.begin(), + for (SmallVectorImpl<ValueDecl *>::iterator I = BlockByCopyDecls.begin(), E = BlockByCopyDecls.end(); I != E; ++I) { if (isObjCType((*I)->getType())) { // FIXME: Conform to ABI ([[obj retain] autorelease]). @@ -5554,7 +5561,7 @@ Stmt *RewriteModernObjC::SynthBlockInitExpr(BlockExpr *Exp, InitExprs.push_back(Exp); } // Output all "by ref" declarations. - for (SmallVector<ValueDecl*,8>::iterator I = BlockByRefDecls.begin(), + for (SmallVectorImpl<ValueDecl *>::iterator I = BlockByRefDecls.begin(), E = BlockByRefDecls.end(); I != E; ++I) { ValueDecl *ND = (*I); std::string Name(ND->getNameAsString()); @@ -6166,6 +6173,11 @@ void RewriteModernObjC::Initialize(ASTContext &context) { Preamble += "__OBJC_RW_DLLIMPORT int objc_sync_enter( struct objc_object *);\n"; Preamble += "__OBJC_RW_DLLIMPORT int objc_sync_exit( struct objc_object *);\n"; Preamble += "__OBJC_RW_DLLIMPORT Protocol *objc_getProtocol(const char *);\n"; + Preamble += "#ifdef _WIN64\n"; + Preamble += "typedef unsigned long long _WIN_NSUInteger;\n"; + Preamble += "#else\n"; + Preamble += "typedef unsigned int _WIN_NSUInteger;\n"; + Preamble += "#endif\n"; Preamble += "#ifndef __FASTENUMERATIONSTATE\n"; Preamble += "struct __objcFastEnumerationState {\n\t"; Preamble += "unsigned long state;\n\t"; |