diff options
Diffstat (limited to 'contrib/llvm-project/clang/lib/ARCMigrate/ARCMT.cpp')
-rw-r--r-- | contrib/llvm-project/clang/lib/ARCMigrate/ARCMT.cpp | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/contrib/llvm-project/clang/lib/ARCMigrate/ARCMT.cpp b/contrib/llvm-project/clang/lib/ARCMigrate/ARCMT.cpp index 36fbe90e1e3a..b410d5f3b42a 100644 --- a/contrib/llvm-project/clang/lib/ARCMigrate/ARCMT.cpp +++ b/contrib/llvm-project/clang/lib/ARCMigrate/ARCMT.cpp @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#include "Internals.h" #include "clang/ARCMigrate/ARCMT.h" +#include "Internals.h" #include "clang/AST/ASTConsumer.h" #include "clang/Basic/DiagnosticCategories.h" #include "clang/Frontend/ASTUnit.h" @@ -20,8 +20,8 @@ #include "clang/Rewrite/Core/Rewriter.h" #include "clang/Sema/SemaDiagnostic.h" #include "clang/Serialization/ASTReader.h" -#include "llvm/ADT/Triple.h" #include "llvm/Support/MemoryBuffer.h" +#include "llvm/TargetParser/Triple.h" #include <utility> using namespace clang; using namespace arcmt; @@ -65,7 +65,7 @@ bool CapturedDiagList::hasDiagnostic(ArrayRef<unsigned> IDs, while (I != List.end()) { FullSourceLoc diagLoc = I->getLocation(); if ((IDs.empty() || // empty means any diagnostic in the range. - llvm::find(IDs, I->getID()) != IDs.end()) && + llvm::is_contained(IDs, I->getID())) && !diagLoc.isBeforeInTranslationUnitThan(range.getBegin()) && (diagLoc == range.getEnd() || diagLoc.isBeforeInTranslationUnitThan(range.getEnd()))) { @@ -162,9 +162,7 @@ static bool HasARCRuntime(CompilerInvocation &origCI) { return triple.getOSMajorVersion() >= 11; if (triple.getOS() == llvm::Triple::MacOSX) { - unsigned Major, Minor, Micro; - triple.getOSVersion(Major, Minor, Micro); - return Major > 10 || (Major == 10 && Minor >= 7); + return triple.getOSVersion() >= VersionTuple(10, 7); } return false; @@ -193,8 +191,8 @@ createInvocationForMigration(CompilerInvocation &origCI, std::string define = std::string(getARCMTMacroName()); define += '='; CInvok->getPreprocessorOpts().addMacroDef(define); - CInvok->getLangOpts()->ObjCAutoRefCount = true; - CInvok->getLangOpts()->setGC(LangOptions::NonGC); + CInvok->getLangOpts().ObjCAutoRefCount = true; + CInvok->getLangOpts().setGC(LangOptions::NonGC); CInvok->getDiagnosticOpts().ErrorLimit = 0; CInvok->getDiagnosticOpts().PedanticErrors = 0; @@ -203,14 +201,14 @@ createInvocationForMigration(CompilerInvocation &origCI, for (std::vector<std::string>::iterator I = CInvok->getDiagnosticOpts().Warnings.begin(), E = CInvok->getDiagnosticOpts().Warnings.end(); I != E; ++I) { - if (!StringRef(*I).startswith("error")) + if (!StringRef(*I).starts_with("error")) WarnOpts.push_back(*I); } WarnOpts.push_back("error=arc-unsafe-retained-assign"); CInvok->getDiagnosticOpts().Warnings = std::move(WarnOpts); - CInvok->getLangOpts()->ObjCWeakRuntime = HasARCRuntime(origCI); - CInvok->getLangOpts()->ObjCWeak = CInvok->getLangOpts()->ObjCWeakRuntime; + CInvok->getLangOpts().ObjCWeakRuntime = HasARCRuntime(origCI); + CInvok->getLangOpts().ObjCWeak = CInvok->getLangOpts().ObjCWeakRuntime; return CInvok.release(); } @@ -239,10 +237,10 @@ bool arcmt::checkForManualIssues( std::shared_ptr<PCHContainerOperations> PCHContainerOps, DiagnosticConsumer *DiagClient, bool emitPremigrationARCErrors, StringRef plistOut) { - if (!origCI.getLangOpts()->ObjC) + if (!origCI.getLangOpts().ObjC) return false; - LangOptions::GCMode OrigGCMode = origCI.getLangOpts()->getGC(); + LangOptions::GCMode OrigGCMode = origCI.getLangOpts().getGC(); bool NoNSAllocReallocError = origCI.getMigratorOpts().NoNSAllocReallocError; bool NoFinalizeRemoval = origCI.getMigratorOpts().NoFinalizeRemoval; @@ -340,10 +338,10 @@ applyTransforms(CompilerInvocation &origCI, const FrontendInputFile &Input, std::shared_ptr<PCHContainerOperations> PCHContainerOps, DiagnosticConsumer *DiagClient, StringRef outputDir, bool emitPremigrationARCErrors, StringRef plistOut) { - if (!origCI.getLangOpts()->ObjC) + if (!origCI.getLangOpts().ObjC) return false; - LangOptions::GCMode OrigGCMode = origCI.getLangOpts()->getGC(); + LangOptions::GCMode OrigGCMode = origCI.getLangOpts().getGC(); // Make sure checking is successful first. CompilerInvocation CInvokForCheck(origCI); @@ -374,7 +372,7 @@ applyTransforms(CompilerInvocation &origCI, const FrontendInputFile &Input, DiagClient, /*ShouldOwnClient=*/false)); if (outputDir.empty()) { - origCI.getLangOpts()->ObjCAutoRefCount = true; + origCI.getLangOpts().ObjCAutoRefCount = true; return migration.getRemapper().overwriteOriginal(*Diags); } else { return migration.getRemapper().flushToDisk(outputDir, *Diags); @@ -507,7 +505,7 @@ public: MigrationProcess::RewriteListener::~RewriteListener() { } MigrationProcess::MigrationProcess( - const CompilerInvocation &CI, + CompilerInvocation &CI, std::shared_ptr<PCHContainerOperations> PCHContainerOps, DiagnosticConsumer *diagClient, StringRef outputDir) : OrigCI(CI), PCHContainerOps(std::move(PCHContainerOps)), @@ -579,7 +577,7 @@ bool MigrationProcess::applyTransform(TransformFn trans, Rewriter rewriter(Ctx.getSourceManager(), Ctx.getLangOpts()); TransformActions TA(*Diags, capturedDiags, Ctx, Unit->getPreprocessor()); - MigrationPass pass(Ctx, OrigCI.getLangOpts()->getGC(), + MigrationPass pass(Ctx, OrigCI.getLangOpts().getGC(), Unit->getSema(), TA, capturedDiags, ARCMTMacroLocs); trans(pass); @@ -599,7 +597,8 @@ bool MigrationProcess::applyTransform(TransformFn trans, I = rewriter.buffer_begin(), E = rewriter.buffer_end(); I != E; ++I) { FileID FID = I->first; RewriteBuffer &buf = I->second; - const FileEntry *file = Ctx.getSourceManager().getFileEntryForID(FID); + OptionalFileEntryRef file = + Ctx.getSourceManager().getFileEntryRefForID(FID); assert(file); std::string newFname = std::string(file->getName()); newFname += "-trans"; |