diff options
Diffstat (limited to 'clang/lib/ARCMigrate')
-rw-r--r-- | clang/lib/ARCMigrate/ARCMT.cpp | 7 | ||||
-rw-r--r-- | clang/lib/ARCMigrate/FileRemapper.cpp | 6 | ||||
-rw-r--r-- | clang/lib/ARCMigrate/Internals.h | 4 | ||||
-rw-r--r-- | clang/lib/ARCMigrate/ObjCMT.cpp | 50 | ||||
-rw-r--r-- | clang/lib/ARCMigrate/TransGCAttrs.cpp | 9 | ||||
-rw-r--r-- | clang/lib/ARCMigrate/TransProperties.cpp | 26 | ||||
-rw-r--r-- | clang/lib/ARCMigrate/TransProtectedScope.cpp | 3 | ||||
-rw-r--r-- | clang/lib/ARCMigrate/TransZeroOutPropsInDealloc.cpp | 12 | ||||
-rw-r--r-- | clang/lib/ARCMigrate/Transforms.cpp | 1 |
9 files changed, 57 insertions, 61 deletions
diff --git a/clang/lib/ARCMigrate/ARCMT.cpp b/clang/lib/ARCMigrate/ARCMT.cpp index a9018c1c4bdf..e18def8a0b19 100644 --- a/clang/lib/ARCMigrate/ARCMT.cpp +++ b/clang/lib/ARCMigrate/ARCMT.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "Internals.h" +#include "clang/ARCMigrate/ARCMT.h" #include "clang/AST/ASTConsumer.h" #include "clang/Basic/DiagnosticCategories.h" #include "clang/Frontend/ASTUnit.h" @@ -189,7 +190,7 @@ createInvocationForMigration(CompilerInvocation &origCI, PPOpts.Includes.insert(PPOpts.Includes.begin(), OriginalFile); PPOpts.ImplicitPCHInclude.clear(); } - std::string define = getARCMTMacroName(); + std::string define = std::string(getARCMTMacroName()); define += '='; CInvok->getPreprocessorOpts().addMacroDef(define); CInvok->getLangOpts()->ObjCAutoRefCount = true; @@ -296,7 +297,7 @@ bool arcmt::checkForManualIssues( for (CapturedDiagList::iterator I = capturedDiags.begin(), E = capturedDiags.end(); I != E; ++I) arcDiags.push_back(*I); - writeARCDiagsToPlist(plistOut, arcDiags, + writeARCDiagsToPlist(std::string(plistOut), arcDiags, Ctx.getSourceManager(), Ctx.getLangOpts()); } @@ -598,7 +599,7 @@ bool MigrationProcess::applyTransform(TransformFn trans, RewriteBuffer &buf = I->second; const FileEntry *file = Ctx.getSourceManager().getFileEntryForID(FID); assert(file); - std::string newFname = file->getName(); + std::string newFname = std::string(file->getName()); newFname += "-trans"; SmallString<512> newText; llvm::raw_svector_ostream vecOS(newText); diff --git a/clang/lib/ARCMigrate/FileRemapper.cpp b/clang/lib/ARCMigrate/FileRemapper.cpp index a031fe22ac13..0222583c015b 100644 --- a/clang/lib/ARCMigrate/FileRemapper.cpp +++ b/clang/lib/ARCMigrate/FileRemapper.cpp @@ -43,7 +43,7 @@ std::string FileRemapper::getRemapInfoFile(StringRef outputDir) { assert(!outputDir.empty()); SmallString<128> InfoFile = outputDir; llvm::sys::path::append(InfoFile, "remap"); - return InfoFile.str(); + return std::string(InfoFile.str()); } bool FileRemapper::initFromDisk(StringRef outputDir, DiagnosticsEngine &Diag, @@ -56,7 +56,7 @@ bool FileRemapper::initFromFile(StringRef filePath, DiagnosticsEngine &Diag, bool ignoreIfFilesChanged) { assert(FromToMappings.empty() && "initFromDisk should be called before any remap calls"); - std::string infoFile = filePath; + std::string infoFile = std::string(filePath); if (!llvm::sys::fs::exists(infoFile)) return false; @@ -120,7 +120,7 @@ bool FileRemapper::flushToFile(StringRef outputPath, DiagnosticsEngine &Diag) { using namespace llvm::sys; std::error_code EC; - std::string infoFile = outputPath; + std::string infoFile = std::string(outputPath); llvm::raw_fd_ostream infoOut(infoFile, EC, llvm::sys::fs::OF_None); if (EC) return report(EC.message(), Diag); diff --git a/clang/lib/ARCMigrate/Internals.h b/clang/lib/ARCMigrate/Internals.h index 47fc09317500..ed0136e4867a 100644 --- a/clang/lib/ARCMigrate/Internals.h +++ b/clang/lib/ARCMigrate/Internals.h @@ -9,13 +9,15 @@ #ifndef LLVM_CLANG_LIB_ARCMIGRATE_INTERNALS_H #define LLVM_CLANG_LIB_ARCMIGRATE_INTERNALS_H -#include "clang/ARCMigrate/ARCMT.h" +#include "clang/Basic/LangOptions.h" #include "clang/Basic/Diagnostic.h" +#include "clang/Frontend/MigratorOptions.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Optional.h" #include <list> namespace clang { + class ASTContext; class Sema; class Stmt; diff --git a/clang/lib/ARCMigrate/ObjCMT.cpp b/clang/lib/ARCMigrate/ObjCMT.cpp index 4c6e9f2432f6..51c4a460cc25 100644 --- a/clang/lib/ARCMigrate/ObjCMT.cpp +++ b/clang/lib/ARCMigrate/ObjCMT.cpp @@ -114,21 +114,15 @@ public: return *Summaries; } - ObjCMigrateASTConsumer(StringRef migrateDir, - unsigned astMigrateActions, - FileRemapper &remapper, - FileManager &fileMgr, + ObjCMigrateASTConsumer(StringRef migrateDir, unsigned astMigrateActions, + FileRemapper &remapper, FileManager &fileMgr, const PPConditionalDirectiveRecord *PPRec, - Preprocessor &PP, - bool isOutputFile, + Preprocessor &PP, bool isOutputFile, ArrayRef<std::string> WhiteList) - : MigrateDir(migrateDir), - ASTMigrateActions(astMigrateActions), - NSIntegerTypedefed(nullptr), NSUIntegerTypedefed(nullptr), - Remapper(remapper), FileMgr(fileMgr), PPRec(PPRec), PP(PP), - IsOutputFile(isOutputFile), - FoundationIncluded(false){ - + : MigrateDir(migrateDir), ASTMigrateActions(astMigrateActions), + NSIntegerTypedefed(nullptr), NSUIntegerTypedefed(nullptr), + Remapper(remapper), FileMgr(fileMgr), PPRec(PPRec), PP(PP), + IsOutputFile(isOutputFile), FoundationIncluded(false) { // FIXME: StringSet should have insert(iter, iter) to use here. for (const std::string &Val : WhiteList) WhiteListFilenames.insert(Val); @@ -191,12 +185,10 @@ protected: } // end anonymous namespace ObjCMigrateAction::ObjCMigrateAction( - std::unique_ptr<FrontendAction> WrappedAction, - StringRef migrateDir, - unsigned migrateAction) - : WrapperFrontendAction(std::move(WrappedAction)), MigrateDir(migrateDir), - ObjCMigAction(migrateAction), - CompInst(nullptr) { + std::unique_ptr<FrontendAction> WrappedAction, StringRef migrateDir, + unsigned migrateAction) + : WrapperFrontendAction(std::move(WrappedAction)), MigrateDir(migrateDir), + ObjCMigAction(migrateAction), CompInst(nullptr) { if (MigrateDir.empty()) MigrateDir = "."; // user current directory if none is given. } @@ -533,7 +525,7 @@ static void rewriteToObjCProperty(const ObjCMethodDecl *Getter, // after that; e.g. isContinuous will become continuous. StringRef PropertyNameStringRef(PropertyNameString); PropertyNameStringRef = PropertyNameStringRef.drop_front(LengthOfPrefix); - PropertyNameString = PropertyNameStringRef; + PropertyNameString = std::string(PropertyNameStringRef); bool NoLowering = (isUppercase(PropertyNameString[0]) && PropertyNameString.size() > 1 && isUppercase(PropertyNameString[1])); @@ -994,7 +986,7 @@ static void ReplaceWithClasstype(const ObjCMigrateASTConsumer &ASTC, if (TypeSourceInfo *TSInfo = OM->getReturnTypeSourceInfo()) { TypeLoc TL = TSInfo->getTypeLoc(); R = SourceRange(TL.getBeginLoc(), TL.getEndLoc()); { - ClassString = IDecl->getName(); + ClassString = std::string(IDecl->getName()); ClassString += "*"; } } @@ -1320,7 +1312,7 @@ void ObjCMigrateASTConsumer::migrateFactoryMethod(ASTContext &Ctx, if (!IDecl) return; - std::string StringClassName = IDecl->getName(); + std::string StringClassName = std::string(IDecl->getName()); StringRef LoweredClassName(StringClassName); std::string StringLoweredClassName = LoweredClassName.lower(); LoweredClassName = StringLoweredClassName; @@ -1330,7 +1322,7 @@ void ObjCMigrateASTConsumer::migrateFactoryMethod(ASTContext &Ctx, if (!MethodIdName) return; - std::string MethodName = MethodIdName->getName(); + std::string MethodName = std::string(MethodIdName->getName()); if (OIT_Family == OIT_Singleton || OIT_Family == OIT_ReturnsSelf) { StringRef STRefMethodName(MethodName); size_t len = 0; @@ -1342,7 +1334,7 @@ void ObjCMigrateASTConsumer::migrateFactoryMethod(ASTContext &Ctx, len = strlen("default"); else return; - MethodName = STRefMethodName.substr(len); + MethodName = std::string(STRefMethodName.substr(len)); } std::string MethodNameSubStr = MethodName.substr(0, 3); StringRef MethodNamePrefix(MethodNameSubStr); @@ -1351,7 +1343,7 @@ void ObjCMigrateASTConsumer::migrateFactoryMethod(ASTContext &Ctx, size_t Ix = LoweredClassName.rfind(MethodNamePrefix); if (Ix == StringRef::npos) return; - std::string ClassNamePostfix = LoweredClassName.substr(Ix); + std::string ClassNamePostfix = std::string(LoweredClassName.substr(Ix)); StringRef LoweredMethodName(MethodName); std::string StringLoweredMethodName = LoweredMethodName.lower(); LoweredMethodName = StringLoweredMethodName; @@ -2010,7 +2002,7 @@ static std::vector<std::string> getWhiteListFilenames(StringRef DirPath) { directory_iterator DE; for (; !EC && DI != DE; DI = DI.increment(EC)) { if (is_regular_file(DI->path())) - Filenames.push_back(filename(DI->path())); + Filenames.push_back(std::string(filename(DI->path()))); } return Filenames; @@ -2153,7 +2145,7 @@ private: if (Val.getAsInteger(10, Entry.RemoveLen)) Ignore = true; } else if (Key == "text") { - Entry.Text = Val; + Entry.Text = std::string(Val); } } @@ -2224,7 +2216,7 @@ static std::string applyEditsToTemp(const FileEntry *FE, TmpOut.write(NewText.data(), NewText.size()); TmpOut.close(); - return TempPath.str(); + return std::string(TempPath.str()); } bool arcmt::getFileRemappingsFromFileList( @@ -2277,7 +2269,7 @@ bool arcmt::getFileRemappingsFromFileList( continue; } - remap.emplace_back(I->first->getName(), TempFile); + remap.emplace_back(std::string(I->first->getName()), TempFile); } return hasErrorOccurred; diff --git a/clang/lib/ARCMigrate/TransGCAttrs.cpp b/clang/lib/ARCMigrate/TransGCAttrs.cpp index 5e3162197ed1..8f5f3cff17cb 100644 --- a/clang/lib/ARCMigrate/TransGCAttrs.cpp +++ b/clang/lib/ARCMigrate/TransGCAttrs.cpp @@ -231,8 +231,7 @@ static void checkAllAtProps(MigrationContext &MigrateCtx, SmallVector<std::pair<AttributedTypeLoc, ObjCPropertyDecl *>, 4> ATLs; bool hasWeak = false, hasStrong = false; - ObjCPropertyDecl::PropertyAttributeKind - Attrs = ObjCPropertyDecl::OBJC_PR_noattr; + ObjCPropertyAttribute::Kind Attrs = ObjCPropertyAttribute::kind_noattr; for (IndivPropsTy::iterator PI = IndProps.begin(), PE = IndProps.end(); PI != PE; ++PI) { ObjCPropertyDecl *PD = *PI; @@ -274,7 +273,7 @@ static void checkAllAtProps(MigrationContext &MigrateCtx, else toAttr = "unsafe_unretained"; } - if (Attrs & ObjCPropertyDecl::OBJC_PR_assign) + if (Attrs & ObjCPropertyAttribute::kind_assign) MigrateCtx.rewritePropertyAttribute("assign", toAttr, AtLoc); else MigrateCtx.addPropertyAttribute(toAttr, AtLoc); @@ -302,8 +301,8 @@ static void checkAllProps(MigrationContext &MigrateCtx, for (unsigned i = 0, e = AllProps.size(); i != e; ++i) { ObjCPropertyDecl *PD = AllProps[i]; if (PD->getPropertyAttributesAsWritten() & - (ObjCPropertyDecl::OBJC_PR_assign | - ObjCPropertyDecl::OBJC_PR_readonly)) { + (ObjCPropertyAttribute::kind_assign | + ObjCPropertyAttribute::kind_readonly)) { SourceLocation AtLoc = PD->getAtLoc(); if (AtLoc.isInvalid()) continue; diff --git a/clang/lib/ARCMigrate/TransProperties.cpp b/clang/lib/ARCMigrate/TransProperties.cpp index 0675fb0baeb8..cba2256ef97b 100644 --- a/clang/lib/ARCMigrate/TransProperties.cpp +++ b/clang/lib/ARCMigrate/TransProperties.cpp @@ -168,22 +168,22 @@ private: } void rewriteProperty(PropsTy &props, SourceLocation atLoc) { - ObjCPropertyDecl::PropertyAttributeKind propAttrs = getPropertyAttrs(props); + ObjCPropertyAttribute::Kind propAttrs = getPropertyAttrs(props); - if (propAttrs & (ObjCPropertyDecl::OBJC_PR_copy | - ObjCPropertyDecl::OBJC_PR_unsafe_unretained | - ObjCPropertyDecl::OBJC_PR_strong | - ObjCPropertyDecl::OBJC_PR_weak)) + if (propAttrs & + (ObjCPropertyAttribute::kind_copy | + ObjCPropertyAttribute::kind_unsafe_unretained | + ObjCPropertyAttribute::kind_strong | ObjCPropertyAttribute::kind_weak)) return; - if (propAttrs & ObjCPropertyDecl::OBJC_PR_retain) { + if (propAttrs & ObjCPropertyAttribute::kind_retain) { // strong is the default. return doPropAction(PropAction_RetainReplacedWithStrong, props, atLoc); } bool HasIvarAssignedAPlusOneObject = hasIvarAssignedAPlusOneObject(props); - if (propAttrs & ObjCPropertyDecl::OBJC_PR_assign) { + if (propAttrs & ObjCPropertyAttribute::kind_assign) { if (HasIvarAssignedAPlusOneObject) return doPropAction(PropAction_AssignRemoved, props, atLoc); return doPropAction(PropAction_AssignRewritten, props, atLoc); @@ -287,7 +287,10 @@ private: public: PlusOneAssign(ObjCIvarDecl *D) : Ivar(D) {} - bool VisitBinAssign(BinaryOperator *E) { + bool VisitBinaryOperator(BinaryOperator *E) { + if (E->getOpcode() != BO_Assign) + return true; + Expr *lhs = E->getLHS()->IgnoreParenImpCasts(); if (ObjCIvarRefExpr *RE = dyn_cast<ObjCIvarRefExpr>(lhs)) { if (RE->getDecl() != Ivar) @@ -354,11 +357,10 @@ private: return ty; } - ObjCPropertyDecl::PropertyAttributeKind - getPropertyAttrs(PropsTy &props) const { + ObjCPropertyAttribute::Kind getPropertyAttrs(PropsTy &props) const { assert(!props.empty()); - ObjCPropertyDecl::PropertyAttributeKind - attrs = props[0].PropD->getPropertyAttributesAsWritten(); + ObjCPropertyAttribute::Kind attrs = + props[0].PropD->getPropertyAttributesAsWritten(); #ifndef NDEBUG for (PropsTy::iterator I = props.begin(), E = props.end(); I != E; ++I) diff --git a/clang/lib/ARCMigrate/TransProtectedScope.cpp b/clang/lib/ARCMigrate/TransProtectedScope.cpp index 9e9e9cb7a96d..154e0b54800f 100644 --- a/clang/lib/ARCMigrate/TransProtectedScope.cpp +++ b/clang/lib/ARCMigrate/TransProtectedScope.cpp @@ -11,9 +11,10 @@ // //===----------------------------------------------------------------------===// -#include "Transforms.h" #include "Internals.h" +#include "Transforms.h" #include "clang/AST/ASTContext.h" +#include "clang/Basic/SourceManager.h" #include "clang/Sema/SemaDiagnostic.h" using namespace clang; diff --git a/clang/lib/ARCMigrate/TransZeroOutPropsInDealloc.cpp b/clang/lib/ARCMigrate/TransZeroOutPropsInDealloc.cpp index d28bd378acc1..81e67628fb1f 100644 --- a/clang/lib/ARCMigrate/TransZeroOutPropsInDealloc.cpp +++ b/clang/lib/ARCMigrate/TransZeroOutPropsInDealloc.cpp @@ -118,13 +118,11 @@ public: ObjCPropertyDecl *PD = PID->getPropertyDecl(); ObjCMethodDecl *setterM = PD->getSetterMethodDecl(); if (!(setterM && setterM->isDefined())) { - ObjCPropertyDecl::PropertyAttributeKind AttrKind = - PD->getPropertyAttributes(); - if (AttrKind & - (ObjCPropertyDecl::OBJC_PR_retain | - ObjCPropertyDecl::OBJC_PR_copy | - ObjCPropertyDecl::OBJC_PR_strong)) - SynthesizedProperties[PD] = PID; + ObjCPropertyAttribute::Kind AttrKind = PD->getPropertyAttributes(); + if (AttrKind & (ObjCPropertyAttribute::kind_retain | + ObjCPropertyAttribute::kind_copy | + ObjCPropertyAttribute::kind_strong)) + SynthesizedProperties[PD] = PID; } } } diff --git a/clang/lib/ARCMigrate/Transforms.cpp b/clang/lib/ARCMigrate/Transforms.cpp index 59b80a917e56..e274a540e408 100644 --- a/clang/lib/ARCMigrate/Transforms.cpp +++ b/clang/lib/ARCMigrate/Transforms.cpp @@ -8,6 +8,7 @@ #include "Transforms.h" #include "Internals.h" +#include "clang/ARCMigrate/ARCMT.h" #include "clang/AST/ASTContext.h" #include "clang/AST/RecursiveASTVisitor.h" #include "clang/Analysis/DomainSpecific/CocoaConventions.h" |