diff options
author | dim <dim@FreeBSD.org> | 2016-12-26 20:36:37 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2016-12-26 20:36:37 +0000 |
commit | 06210ae42d418d50d8d9365d5c9419308ae9e7ee (patch) | |
tree | ab60b4cdd6e430dda1f292a46a77ddb744723f31 /contrib/llvm/tools/clang/lib/Frontend/Rewrite/RewriteObjC.cpp | |
parent | 2dd166267f53df1c3748b4325d294b9b839de74b (diff) | |
download | FreeBSD-src-06210ae42d418d50d8d9365d5c9419308ae9e7ee.zip FreeBSD-src-06210ae42d418d50d8d9365d5c9419308ae9e7ee.tar.gz |
MFC r309124:
Upgrade our copies of clang, llvm, lldb, compiler-rt and libc++ to 3.9.0
release, and add lld 3.9.0. Also completely revamp the build system for
clang, llvm, lldb and their related tools.
Please note that from 3.5.0 onwards, clang, llvm and lldb require C++11
support to build; see UPDATING for more information.
Release notes for llvm, clang and lld are available here:
<http://llvm.org/releases/3.9.0/docs/ReleaseNotes.html>
<http://llvm.org/releases/3.9.0/tools/clang/docs/ReleaseNotes.html>
<http://llvm.org/releases/3.9.0/tools/lld/docs/ReleaseNotes.html>
Thanks to Ed Maste, Bryan Drewery, Andrew Turner, Antoine Brodin and Jan
Beich for their help.
Relnotes: yes
MFC r309147:
Pull in r282174 from upstream llvm trunk (by Krzysztof Parzyszek):
[PPC] Set SP after loading data from stack frame, if no red zone is
present
Follow-up to r280705: Make sure that the SP is only restored after
all data is loaded from the stack frame, if there is no red zone.
This completes the fix for
https://llvm.org/bugs/show_bug.cgi?id=26519.
Differential Revision: https://reviews.llvm.org/D24466
Reported by: Mark Millard
PR: 214433
MFC r309149:
Pull in r283060 from upstream llvm trunk (by Hal Finkel):
[PowerPC] Refactor soft-float support, and enable PPC64 soft float
This change enables soft-float for PowerPC64, and also makes
soft-float disable all vector instruction sets for both 32-bit and
64-bit modes. This latter part is necessary because the PPC backend
canonicalizes many Altivec vector types to floating-point types, and
so soft-float breaks scalarization support for many operations. Both
for embedded targets and for operating-system kernels desiring
soft-float support, it seems reasonable that disabling hardware
floating-point also disables vector instructions (embedded targets
without hardware floating point support are unlikely to have Altivec,
etc. and operating system kernels desiring not to use floating-point
registers to lower syscall cost are unlikely to want to use vector
registers either). If someone needs this to work, we'll need to
change the fact that we promote many Altivec operations to act on
v4f32. To make it possible to disable Altivec when soft-float is
enabled, hardware floating-point support needs to be expressed as a
positive feature, like the others, and not a negative feature,
because target features cannot have dependencies on the disabling of
some other feature. So +soft-float has now become -hard-float.
Fixes PR26970.
Pull in r283061 from upstream clang trunk (by Hal Finkel):
[PowerPC] Enable soft-float for PPC64, and +soft-float -> -hard-float
Enable soft-float support on PPC64, as the backend now supports it.
Also, the backend now uses -hard-float instead of +soft-float, so set
the target features accordingly.
Fixes PR26970.
Reported by: Mark Millard
PR: 214433
MFC r309212:
Add a few missed clang 3.9.0 files to OptionalObsoleteFiles.
MFC r309262:
Fix packaging for clang, lldb and lld 3.9.0
During the upgrade of clang/llvm etc to 3.9.0 in r309124, the PACKAGE
directive in the usr.bin/clang/*.mk files got dropped accidentally.
Restore it, with a few minor changes and additions:
* Correct license in clang.ucl to NCSA
* Add PACKAGE=clang for clang and most of the "ll" tools
* Put lldb in its own package
* Put lld in its own package
Reviewed by: gjb, jmallett
Differential Revision: https://reviews.freebsd.org/D8666
MFC r309656:
During the bootstrap phase, when building the minimal llvm library on
PowerPC, add lib/Support/Atomic.cpp. This is needed because upstream
llvm revision r271821 disabled the use of std::call_once, which causes
some fallback functions from Atomic.cpp to be used instead.
Reported by: Mark Millard
PR: 214902
MFC r309835:
Tentatively apply https://reviews.llvm.org/D18730 to work around gcc PR
70528 (bogus error: constructor required before non-static data member).
This should fix buildworld with the external gcc package.
Reported by: https://jenkins.freebsd.org/job/FreeBSD_HEAD_amd64_gcc/
MFC r310194:
Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
3.9.1 release.
Please note that from 3.5.0 onwards, clang, llvm and lldb require C++11
support to build; see UPDATING for more information.
Release notes for llvm, clang and lld will be available here:
<http://releases.llvm.org/3.9.1/docs/ReleaseNotes.html>
<http://releases.llvm.org/3.9.1/tools/clang/docs/ReleaseNotes.html>
<http://releases.llvm.org/3.9.1/tools/lld/docs/ReleaseNotes.html>
Relnotes: yes
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Frontend/Rewrite/RewriteObjC.cpp')
-rw-r--r-- | contrib/llvm/tools/clang/lib/Frontend/Rewrite/RewriteObjC.cpp | 107 |
1 files changed, 43 insertions, 64 deletions
diff --git a/contrib/llvm/tools/clang/lib/Frontend/Rewrite/RewriteObjC.cpp b/contrib/llvm/tools/clang/lib/Frontend/Rewrite/RewriteObjC.cpp index e0ddadb..5967e40 100644 --- a/contrib/llvm/tools/clang/lib/Frontend/Rewrite/RewriteObjC.cpp +++ b/contrib/llvm/tools/clang/lib/Frontend/Rewrite/RewriteObjC.cpp @@ -37,7 +37,6 @@ using llvm::utostr; namespace { class RewriteObjC : public ASTConsumer { protected: - enum { BLOCK_FIELD_IS_OBJECT = 3, /* id, NSObject, __attribute__((NSObject)), block, ... */ @@ -72,7 +71,7 @@ namespace { Stmt *CurrentBody; ParentMap *PropParentMap; // created lazily. std::string InFileName; - raw_ostream* OutFile; + std::unique_ptr<raw_ostream> OutFile; std::string Preamble; TypeDecl *ProtocolTypeDecl; @@ -158,14 +157,15 @@ namespace { : R(R), SavedValue(R.DisableReplaceStmt) { R.DisableReplaceStmt = true; } + ~DisableReplaceStmtScope() { R.DisableReplaceStmt = SavedValue; } }; + void InitializeCommon(ASTContext &context); public: - // Top Level Driver code. bool HandleTopLevelDecl(DeclGroupRef D) override { for (DeclGroupRef::iterator I = D.begin(), E = D.end(); I != E; ++I) { @@ -187,9 +187,10 @@ namespace { } return true; } + void HandleTopLevelSingleDecl(Decl *D); void HandleDeclInMainFile(Decl *D); - RewriteObjC(std::string inFile, raw_ostream *OS, + RewriteObjC(std::string inFile, std::unique_ptr<raw_ostream> OS, DiagnosticsEngine &D, const LangOptions &LOpts, bool silenceMacroWarn); @@ -505,12 +506,10 @@ namespace { class RewriteObjCFragileABI : public RewriteObjC { public: - - RewriteObjCFragileABI(std::string inFile, raw_ostream *OS, - DiagnosticsEngine &D, const LangOptions &LOpts, - bool silenceMacroWarn) : RewriteObjC(inFile, OS, - D, LOpts, - silenceMacroWarn) {} + RewriteObjCFragileABI(std::string inFile, std::unique_ptr<raw_ostream> OS, + DiagnosticsEngine &D, const LangOptions &LOpts, + bool silenceMacroWarn) + : RewriteObjC(inFile, std::move(OS), D, LOpts, silenceMacroWarn) {} ~RewriteObjCFragileABI() override {} void Initialize(ASTContext &context) override; @@ -540,7 +539,7 @@ namespace { std::string &Result) override; Stmt *RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) override; }; -} +} // end anonymous namespace void RewriteObjC::RewriteBlocksInFunctionProtoType(QualType funcType, NamedDecl *D) { @@ -575,11 +574,11 @@ static bool IsHeaderFile(const std::string &Filename) { return Ext == "h" || Ext == "hh" || Ext == "H"; } -RewriteObjC::RewriteObjC(std::string inFile, raw_ostream* OS, +RewriteObjC::RewriteObjC(std::string inFile, std::unique_ptr<raw_ostream> OS, DiagnosticsEngine &D, const LangOptions &LOpts, bool silenceMacroWarn) - : Diags(D), LangOpts(LOpts), InFileName(inFile), OutFile(OS), - SilenceRewriteMacroWarning(silenceMacroWarn) { + : Diags(D), LangOpts(LOpts), InFileName(inFile), OutFile(std::move(OS)), + SilenceRewriteMacroWarning(silenceMacroWarn) { IsHeader = IsHeaderFile(inFile); RewriteFailedDiag = Diags.getCustomDiagID(DiagnosticsEngine::Warning, "rewriting sub-expression within a macro (may not be correct)"); @@ -590,11 +589,12 @@ RewriteObjC::RewriteObjC(std::string inFile, raw_ostream* OS, } std::unique_ptr<ASTConsumer> -clang::CreateObjCRewriter(const std::string &InFile, raw_ostream *OS, +clang::CreateObjCRewriter(const std::string &InFile, + std::unique_ptr<raw_ostream> OS, DiagnosticsEngine &Diags, const LangOptions &LOpts, bool SilenceRewriteMacroWarning) { - return llvm::make_unique<RewriteObjCFragileABI>(InFile, OS, Diags, LOpts, - SilenceRewriteMacroWarning); + return llvm::make_unique<RewriteObjCFragileABI>( + InFile, std::move(OS), Diags, LOpts, SilenceRewriteMacroWarning); } void RewriteObjC::InitializeCommon(ASTContext &context) { @@ -969,7 +969,7 @@ void RewriteObjC::RewriteCategoryDecl(ObjCCategoryDecl *CatDecl) { // FIXME: handle category headers that are declared across multiple lines. ReplaceText(LocStart, 0, "// "); - for (auto *I : CatDecl->properties()) + for (auto *I : CatDecl->instance_properties()) RewriteProperty(I); for (auto *I : CatDecl->instance_methods()) RewriteMethodDeclaration(I); @@ -992,7 +992,7 @@ void RewriteObjC::RewriteProtocolDecl(ObjCProtocolDecl *PDecl) { RewriteMethodDeclaration(I); for (auto *I : PDecl->class_methods()) RewriteMethodDeclaration(I); - for (auto *I : PDecl->properties()) + for (auto *I : PDecl->instance_properties()) RewriteProperty(I); // Lastly, comment out the @end. @@ -1118,7 +1118,7 @@ void RewriteObjC::RewriteObjCMethodDecl(const ObjCInterfaceDecl *IDecl, ResultStr += " _cmd"; // Method arguments. - for (const auto *PDecl : OMD->params()) { + for (const auto *PDecl : OMD->parameters()) { ResultStr += ", "; if (PDecl->getType()->isObjCQualifiedIdType()) { ResultStr += "id "; @@ -1159,6 +1159,7 @@ void RewriteObjC::RewriteObjCMethodDecl(const ObjCInterfaceDecl *IDecl, } } } + void RewriteObjC::RewriteImplementationDecl(Decl *OID) { ObjCImplementationDecl *IMD = dyn_cast<ObjCImplementationDecl>(OID); ObjCCategoryImplDecl *CID = dyn_cast<ObjCCategoryImplDecl>(OID); @@ -1210,7 +1211,7 @@ void RewriteObjC::RewriteInterfaceDecl(ObjCInterfaceDecl *ClassDecl) { } RewriteObjCInternalStruct(ClassDecl, ResultStr); - for (auto *I : ClassDecl->properties()) + for (auto *I : ClassDecl->instance_properties()) RewriteProperty(I); for (auto *I : ClassDecl->instance_methods()) RewriteMethodDeclaration(I); @@ -1720,7 +1721,6 @@ void RewriteObjC::WarnAboutReturnGotoStmts(Stmt *S) Diags.Report(Context->getFullLoc(S->getLocStart()), TryFinallyContainsReturnDiag); } - return; } void RewriteObjC::HasReturnStmts(Stmt *S, bool &hasReturns) @@ -1730,32 +1730,29 @@ void RewriteObjC::HasReturnStmts(Stmt *S, bool &hasReturns) if (SubStmt) HasReturnStmts(SubStmt, hasReturns); - if (isa<ReturnStmt>(S)) - hasReturns = true; - return; + if (isa<ReturnStmt>(S)) + hasReturns = true; } void RewriteObjC::RewriteTryReturnStmts(Stmt *S) { - // Perform a bottom up traversal of all children. - for (Stmt *SubStmt : S->children()) - if (SubStmt) { - RewriteTryReturnStmts(SubStmt); - } - if (isa<ReturnStmt>(S)) { - SourceLocation startLoc = S->getLocStart(); - const char *startBuf = SM->getCharacterData(startLoc); - - const char *semiBuf = strchr(startBuf, ';'); - assert((*semiBuf == ';') && "RewriteTryReturnStmts: can't find ';'"); - SourceLocation onePastSemiLoc = startLoc.getLocWithOffset(semiBuf-startBuf+1); + // Perform a bottom up traversal of all children. + for (Stmt *SubStmt : S->children()) + if (SubStmt) { + RewriteTryReturnStmts(SubStmt); + } + if (isa<ReturnStmt>(S)) { + SourceLocation startLoc = S->getLocStart(); + const char *startBuf = SM->getCharacterData(startLoc); + const char *semiBuf = strchr(startBuf, ';'); + assert((*semiBuf == ';') && "RewriteTryReturnStmts: can't find ';'"); + SourceLocation onePastSemiLoc = startLoc.getLocWithOffset(semiBuf-startBuf+1); - std::string buf; - buf = "{ objc_exception_try_exit(&_stack); return"; + std::string buf; + buf = "{ objc_exception_try_exit(&_stack); return"; - ReplaceText(startLoc, 6, buf); - InsertText(onePastSemiLoc, "}"); - } - return; + ReplaceText(startLoc, 6, buf); + InsertText(onePastSemiLoc, "}"); + } } void RewriteObjC::RewriteSyncReturnStmts(Stmt *S, std::string syncExitBuf) { @@ -1780,7 +1777,6 @@ void RewriteObjC::RewriteSyncReturnStmts(Stmt *S, std::string syncExitBuf) { ReplaceText(startLoc, 6, buf); InsertText(onePastSemiLoc, "}"); } - return; } Stmt *RewriteObjC::RewriteObjCTryStmt(ObjCAtTryStmt *S) { @@ -2287,7 +2283,6 @@ void RewriteObjC::RewriteBlockPointerTypeVariable(std::string& Str, } } - void RewriteObjC::RewriteBlockLiteralFunctionDecl(FunctionDecl *FD) { SourceLocation FunLocStart = FD->getTypeSpecStartLoc(); const FunctionType *funcType = FD->getType()->getAs<FunctionType>(); @@ -2615,10 +2610,8 @@ CallExpr *RewriteObjC::SynthMsgSendStretCallExpr(FunctionDecl *MsgSendStretFlavo CallExpr *STCE = new (Context) CallExpr( *Context, PE, MsgExprs, FT->getReturnType(), VK_RValue, SourceLocation()); return STCE; - } - Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, SourceLocation StartLoc, SourceLocation EndLoc) { @@ -2924,7 +2917,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, ArgTypes.push_back(Context->getObjCSelType()); if (ObjCMethodDecl *OMD = Exp->getMethodDecl()) { // Push any user argument types. - for (const auto *PI : OMD->params()) { + for (const auto *PI : OMD->parameters()) { QualType t = PI->getType()->isObjCQualifiedIdType() ? Context->getObjCIdType() : PI->getType(); @@ -3059,7 +3052,6 @@ Stmt *RewriteObjC::RewriteObjCProtocolExpr(ObjCProtocolExpr *Exp) { ProtocolExprDecls.insert(Exp->getProtocol()->getCanonicalDecl()); // delete Exp; leak for now, see RewritePropertyOrImplicitSetter() usage for more info. return castExpr; - } bool RewriteObjC::BufferContainsPPDirectives(const char *startBuf, @@ -3224,7 +3216,6 @@ void RewriteObjC::RewriteObjCInternalStruct(ObjCInterfaceDecl *CDecl, // Meta Data Emission //===----------------------------------------------------------------------===// - /// RewriteImplementations - This routine rewrites all method implementations /// and emits meta-data. @@ -3665,8 +3656,6 @@ void RewriteObjC::GetBlockDeclRefExprs(Stmt *S) { HasLocalVariableExternalStorage(DRE->getDecl())) // FIXME: Handle enums. BlockDeclRefs.push_back(DRE); - - return; } void RewriteObjC::GetInnerBlockDeclRefExprs(Stmt *S, @@ -3694,8 +3683,6 @@ void RewriteObjC::GetInnerBlockDeclRefExprs(Stmt *S, ImportedLocalExternalDecls.insert(Var); } } - - return; } /// convertFunctionTypeOfBlocks - This routine converts a function type @@ -3761,7 +3748,7 @@ Stmt *RewriteObjC::SynthesizeBlockCall(CallExpr *Exp, const Expr *BlockExp) { = dyn_cast<PseudoObjectExpr>(BlockExp)) { CPT = POE->getType()->castAs<BlockPointerType>(); } else { - assert(1 && "RewriteBlockClass: Bad type"); + assert(false && "RewriteBlockClass: Bad type"); } assert(CPT && "RewriteBlockClass: Bad type"); const FunctionType *FT = CPT->getPointeeType()->getAs<FunctionType>(); @@ -3931,7 +3918,6 @@ void RewriteObjC::RewriteCastExpr(CStyleCastExpr *CE) { break; } } - return; } void RewriteObjC::RewriteBlockPointerFunctionArgs(FunctionDecl *FD) { @@ -3966,7 +3952,6 @@ void RewriteObjC::RewriteBlockPointerFunctionArgs(FunctionDecl *FD) { break; } } - return; } bool RewriteObjC::PointerTypeTakesAnyBlockArguments(QualType QT) { @@ -4103,11 +4088,8 @@ void RewriteObjC::RewriteBlockPointerDecl(NamedDecl *ND) { OrigLength++; } ReplaceText(Start, OrigLength, buf); - - return; } - /// SynthesizeByrefCopyDestroyHelper - This routine synthesizes: /// void __Block_byref_id_object_copy(struct Block_byref_id_object *dst, /// struct Block_byref_id_object *src) { @@ -4328,7 +4310,6 @@ void RewriteObjC::RewriteByRefVar(VarDecl *ND) { InsertText(semiLoc, "}"); } - return; } void RewriteObjC::CollectBlockDeclRefInfo(BlockExpr *Exp) { @@ -4494,7 +4475,6 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp, Exp = new (Context) UnaryOperator(Exp, UO_AddrOf, QT, VK_RValue, OK_Ordinary, SourceLocation()); } - } InitExprs.push_back(Exp); } @@ -5241,7 +5221,6 @@ void RewriteObjCFragileABI::RewriteObjCProtocolMetaData( // Mark this protocol as having been generated. if (!ObjCSynthesizedProtocols.insert(PDecl->getCanonicalDecl()).second) llvm_unreachable("protocol already synthesized"); - } void RewriteObjCFragileABI::RewriteObjCProtocolListMetaData( @@ -5910,4 +5889,4 @@ Stmt *RewriteObjCFragileABI::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) { return Replacement; } -#endif +#endif // CLANG_ENABLE_OBJC_REWRITER |