From 9a16beb8bc580212df519aa488242a94e53741d8 Mon Sep 17 00:00:00 2001 From: Ahmed Charles Date: Fri, 7 Mar 2014 19:33:25 +0000 Subject: [PATCH] Change OwningPtr::take() to OwningPtr::release(). This is a precursor to moving to std::unique_ptr. llvm-svn: 203275 --- clang/include/clang/Basic/FileSystemStatCache.h | 4 ++-- clang/include/clang/Frontend/CompilerInstance.h | 10 +++++----- clang/include/clang/Frontend/FrontendAction.h | 4 +--- clang/include/clang/Lex/Preprocessor.h | 10 +++------- clang/include/clang/Serialization/ASTReader.h | 2 +- .../StaticAnalyzer/Core/PathSensitive/CoreEngine.h | 2 +- clang/lib/ARCMigrate/ARCMT.cpp | 9 ++++----- clang/lib/ARCMigrate/ObjCMT.cpp | 2 +- clang/lib/Analysis/CFG.cpp | 2 +- clang/lib/Analysis/Consumed.cpp | 4 ++-- clang/lib/Basic/FileManager.cpp | 12 ++++++------ clang/lib/Basic/FileSystemStatCache.cpp | 2 +- clang/lib/Basic/Targets.cpp | 2 +- clang/lib/Basic/VirtualFileSystem.cpp | 2 +- clang/lib/CodeGen/BackendUtil.cpp | 2 +- clang/lib/CodeGen/CodeGenAction.cpp | 20 ++++++++------------ clang/lib/CodeGen/ModuleBuilder.cpp | 4 +--- clang/lib/Driver/Driver.cpp | 6 +++--- clang/lib/Format/UnwrappedLineParser.cpp | 2 +- clang/lib/Frontend/ASTUnit.cpp | 11 ++++++----- clang/lib/Frontend/ChainedIncludesSource.cpp | 8 ++++---- clang/lib/Frontend/CompilerInstance.cpp | 11 +++++------ .../lib/Frontend/CreateInvocationFromCommandLine.cpp | 2 +- clang/lib/Frontend/FrontendAction.cpp | 4 ++-- clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp | 4 ++-- clang/lib/Lex/HeaderMap.cpp | 2 +- clang/lib/Lex/PPLexerChange.cpp | 4 ++-- clang/lib/Lex/PTHLexer.cpp | 6 +++--- clang/lib/Serialization/GlobalModuleIndex.cpp | 5 +++-- clang/lib/StaticAnalyzer/Core/BugReporter.cpp | 2 +- clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp | 4 ++-- .../lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp | 2 +- .../StaticAnalyzer/Frontend/CheckerRegistration.cpp | 2 +- clang/lib/Tooling/JSONCompilationDatabase.cpp | 10 +++++----- clang/lib/Tooling/Tooling.cpp | 2 +- clang/tools/driver/cc1_main.cpp | 2 +- clang/tools/driver/cc1as_main.cpp | 2 +- clang/tools/libclang/ARCMigrate.cpp | 8 ++++---- clang/tools/libclang/CIndex.cpp | 4 ++-- clang/tools/libclang/CXLoadedDiagnostic.cpp | 4 ++-- clang/unittests/Sema/ExternalSemaSourceTest.cpp | 10 +++++----- 41 files changed, 99 insertions(+), 111 deletions(-) diff --git a/clang/include/clang/Basic/FileSystemStatCache.h b/clang/include/clang/Basic/FileSystemStatCache.h index 7ed0acc..05b65ee 100644 --- a/clang/include/clang/Basic/FileSystemStatCache.h +++ b/clang/include/clang/Basic/FileSystemStatCache.h @@ -82,8 +82,8 @@ public: /// \brief Retrieve the next stat call cache in the chain, transferring /// ownership of this cache (and, transitively, all of the remaining caches) /// to the caller. - FileSystemStatCache *takeNextStatCache() { return NextStatCache.take(); } - + FileSystemStatCache *takeNextStatCache() { return NextStatCache.release(); } + protected: virtual LookupResult getStat(const char *Path, FileData &Data, bool isFile, vfs::File **F, vfs::FileSystem &FS) = 0; diff --git a/clang/include/clang/Frontend/CompilerInstance.h b/clang/include/clang/Frontend/CompilerInstance.h index 29627fa..7c4d754 100644 --- a/clang/include/clang/Frontend/CompilerInstance.h +++ b/clang/include/clang/Frontend/CompilerInstance.h @@ -435,7 +435,7 @@ public: /// takeASTConsumer - Remove the current AST consumer and give ownership to /// the caller. - ASTConsumer *takeASTConsumer() { return Consumer.take(); } + ASTConsumer *takeASTConsumer() { return Consumer.release(); } /// setASTConsumer - Replace the current AST consumer; the compiler instance /// takes ownership of \p Value. @@ -450,9 +450,9 @@ public: assert(TheSema && "Compiler instance has no Sema object!"); return *TheSema; } - - Sema *takeSema() { return TheSema.take(); } - + + Sema *takeSema() { return TheSema.release(); } + /// } /// @name Module Management /// { @@ -477,7 +477,7 @@ public: /// takeCodeCompletionConsumer - Remove the current code completion consumer /// and give ownership to the caller. CodeCompleteConsumer *takeCodeCompletionConsumer() { - return CompletionConsumer.take(); + return CompletionConsumer.release(); } /// setCodeCompletionConsumer - Replace the current code completion consumer; diff --git a/clang/include/clang/Frontend/FrontendAction.h b/clang/include/clang/Frontend/FrontendAction.h index a568ba0..07b60c0 100644 --- a/clang/include/clang/Frontend/FrontendAction.h +++ b/clang/include/clang/Frontend/FrontendAction.h @@ -146,9 +146,7 @@ public: return *CurrentASTUnit; } - ASTUnit *takeCurrentASTUnit() { - return CurrentASTUnit.take(); - } + ASTUnit *takeCurrentASTUnit() { return CurrentASTUnit.release(); } void setCurrentInput(const FrontendInputFile &CurrentInput, ASTUnit *AST = 0); diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h index d01c4a1..e0cfc82 100644 --- a/clang/include/clang/Lex/Preprocessor.h +++ b/clang/include/clang/Lex/Preprocessor.h @@ -1326,13 +1326,9 @@ public: private: void PushIncludeMacroStack() { - IncludeMacroStack.push_back(IncludeStackInfo(CurLexerKind, - CurSubmodule, - CurLexer.take(), - CurPTHLexer.take(), - CurPPLexer, - CurTokenLexer.take(), - CurDirLookup)); + IncludeMacroStack.push_back(IncludeStackInfo( + CurLexerKind, CurSubmodule, CurLexer.release(), CurPTHLexer.release(), + CurPPLexer, CurTokenLexer.release(), CurDirLookup)); CurPPLexer = 0; } diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h index f171eb9..2dc1d28 100644 --- a/clang/include/clang/Serialization/ASTReader.h +++ b/clang/include/clang/Serialization/ASTReader.h @@ -1325,7 +1325,7 @@ public: /// Takes ownership of \p L. void addListener(ASTReaderListener *L) { if (Listener) - L = new ChainedASTReaderListener(L, Listener.take()); + L = new ChainedASTReaderListener(L, Listener.release()); Listener.reset(L); } diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h index a2e211e..e38fd88 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h @@ -120,7 +120,7 @@ public: /// takeGraph - Returns the exploded graph. Ownership of the graph is /// transferred to the caller. - ExplodedGraph* takeGraph() { return G.take(); } + ExplodedGraph *takeGraph() { return G.release(); } /// ExecuteWorkList - Run the worklist algorithm for a maximum number of /// steps. Returns true if there is still simulation state on the worklist. diff --git a/clang/lib/ARCMigrate/ARCMT.cpp b/clang/lib/ARCMigrate/ARCMT.cpp index 0593a36..f8c477b 100644 --- a/clang/lib/ARCMigrate/ARCMT.cpp +++ b/clang/lib/ARCMigrate/ARCMT.cpp @@ -208,7 +208,7 @@ createInvocationForMigration(CompilerInvocation &origCI) { CInvok->getLangOpts()->ObjCARCWeak = HasARCRuntime(origCI); - return CInvok.take(); + return CInvok.release(); } static void emitPremigrationErrors(const CapturedDiagList &arcDiags, @@ -264,7 +264,7 @@ bool arcmt::checkForManualIssues(CompilerInvocation &origCI, Diags->setClient(&errRec, /*ShouldOwnClient=*/false); OwningPtr Unit( - ASTUnit::LoadFromCompilerInvocationAction(CInvok.take(), Diags)); + ASTUnit::LoadFromCompilerInvocationAction(CInvok.release(), Diags)); if (!Unit) { errRec.FinishCapture(); return true; @@ -537,9 +537,8 @@ bool MigrationProcess::applyTransform(TransformFn trans, OwningPtr ASTAction; ASTAction.reset(new ARCMTMacroTrackerAction(ARCMTMacroLocs)); - OwningPtr Unit( - ASTUnit::LoadFromCompilerInvocationAction(CInvok.take(), Diags, - ASTAction.get())); + OwningPtr Unit(ASTUnit::LoadFromCompilerInvocationAction( + CInvok.release(), Diags, ASTAction.get())); if (!Unit) { errRec.FinishCapture(); return true; diff --git a/clang/lib/ARCMigrate/ObjCMT.cpp b/clang/lib/ARCMigrate/ObjCMT.cpp index a527e0c..d8d8419 100644 --- a/clang/lib/ARCMigrate/ObjCMT.cpp +++ b/clang/lib/ARCMigrate/ObjCMT.cpp @@ -1993,7 +1993,7 @@ public: return true; llvm::SourceMgr SM; - Stream YAMLStream(FileBuf.take(), SM); + Stream YAMLStream(FileBuf.release(), SM); document_iterator I = YAMLStream.begin(); if (I == YAMLStream.end()) return true; diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp index f11db62..da953b7 100644 --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/lib/Analysis/CFG.cpp @@ -724,7 +724,7 @@ CFG* CFGBuilder::buildCFG(const Decl *D, Stmt *Statement) { // Create an empty entry block that has no predecessors. cfg->setEntry(createBlock()); - return cfg.take(); + return cfg.release(); } /// createBlock - Used to lazily create blocks that are connected diff --git a/clang/lib/Analysis/Consumed.cpp b/clang/lib/Analysis/Consumed.cpp index 63c5c86..23fc437 100644 --- a/clang/lib/Analysis/Consumed.cpp +++ b/clang/lib/Analysis/Consumed.cpp @@ -1362,8 +1362,8 @@ bool ConsumedAnalyzer::splitState(const CFGBlock *CurrBlock, delete CurrStates; if (*++SI) - BlockInfo.addInfo(*SI, FalseStates.take()); - + BlockInfo.addInfo(*SI, FalseStates.release()); + CurrStates = NULL; return true; } diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp index 5784f31..4431e45 100644 --- a/clang/lib/Basic/FileManager.cpp +++ b/clang/lib/Basic/FileManager.cpp @@ -71,7 +71,7 @@ void FileManager::addStatCache(FileSystemStatCache *statCache, bool AtBeginning) { assert(statCache && "No stat cache provided?"); if (AtBeginning || StatCache.get() == 0) { - statCache->setNextStatCache(StatCache.take()); + statCache->setNextStatCache(StatCache.release()); StatCache.reset(statCache); return; } @@ -395,7 +395,7 @@ getBufferForFile(const FileEntry *Entry, std::string *ErrorStr, if (ErrorStr) *ErrorStr = ec.message(); Entry->closeFile(); - return Result.take(); + return Result.release(); } // Otherwise, open the file. @@ -404,7 +404,7 @@ getBufferForFile(const FileEntry *Entry, std::string *ErrorStr, ec = FS->getBufferForFile(Filename, Result, FileSize); if (ec && ErrorStr) *ErrorStr = ec.message(); - return Result.take(); + return Result.release(); } SmallString<128> FilePath(Entry->getName()); @@ -412,7 +412,7 @@ getBufferForFile(const FileEntry *Entry, std::string *ErrorStr, ec = FS->getBufferForFile(FilePath.str(), Result, FileSize); if (ec && ErrorStr) *ErrorStr = ec.message(); - return Result.take(); + return Result.release(); } llvm::MemoryBuffer *FileManager:: @@ -423,7 +423,7 @@ getBufferForFile(StringRef Filename, std::string *ErrorStr) { ec = FS->getBufferForFile(Filename, Result); if (ec && ErrorStr) *ErrorStr = ec.message(); - return Result.take(); + return Result.release(); } SmallString<128> FilePath(Filename); @@ -431,7 +431,7 @@ getBufferForFile(StringRef Filename, std::string *ErrorStr) { ec = FS->getBufferForFile(FilePath.c_str(), Result); if (ec && ErrorStr) *ErrorStr = ec.message(); - return Result.take(); + return Result.release(); } /// getStatValue - Get the 'stat' information for the specified path, diff --git a/clang/lib/Basic/FileSystemStatCache.cpp b/clang/lib/Basic/FileSystemStatCache.cpp index e50dc1b..dfab929 100644 --- a/clang/lib/Basic/FileSystemStatCache.cpp +++ b/clang/lib/Basic/FileSystemStatCache.cpp @@ -91,7 +91,7 @@ bool FileSystemStatCache::get(const char *Path, FileData &Data, bool isFile, if (Status) { R = CacheExists; copyStatusToFileData(*Status, Data); - *F = OwnedFile.take(); + *F = OwnedFile.release(); } else { // fstat rarely fails. If it does, claim the initial open didn't // succeed. diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index 6df7b95..a839b6a 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -6015,5 +6015,5 @@ TargetInfo *TargetInfo::CreateTargetInfo(DiagnosticsEngine &Diags, if (!Target->handleTargetFeatures(Opts->Features, Diags)) return 0; - return Target.take(); + return Target.release(); } diff --git a/clang/lib/Basic/VirtualFileSystem.cpp b/clang/lib/Basic/VirtualFileSystem.cpp index 28bb598..3775fda 100644 --- a/clang/lib/Basic/VirtualFileSystem.cpp +++ b/clang/lib/Basic/VirtualFileSystem.cpp @@ -731,7 +731,7 @@ VFSFromYAML *VFSFromYAML::create(MemoryBuffer *Buffer, if (!P.parse(Root, FS.get())) return NULL; - return FS.take(); + return FS.release(); } ErrorOr VFSFromYAML::lookupPath(const Twine &Path_) { diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 478993a..dbc62b7 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -119,7 +119,7 @@ public: delete PerModulePasses; delete PerFunctionPasses; if (CodeGenOpts.DisableFree) - BuryPointer(TM.take()); + BuryPointer(TM.release()); } llvm::OwningPtr TM; diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp index 3a09127..280d764 100644 --- a/clang/lib/CodeGen/CodeGenAction.cpp +++ b/clang/lib/CodeGen/CodeGenAction.cpp @@ -66,8 +66,8 @@ namespace clang { llvm::TimePassesIsEnabled = TimePasses; } - llvm::Module *takeModule() { return TheModule.take(); } - llvm::Module *takeLinkModule() { return LinkModule.take(); } + llvm::Module *takeModule() { return TheModule.release(); } + llvm::Module *takeLinkModule() { return LinkModule.release(); } virtual void HandleCXXStaticMemberVarInstantiation(VarDecl *VD) { Gen->HandleCXXStaticMemberVarInstantiation(VD); @@ -125,7 +125,7 @@ namespace clang { if (!M) { // The module has been released by IR gen on failures, do not double // free. - TheModule.take(); + TheModule.release(); return; } @@ -435,9 +435,7 @@ void CodeGenAction::EndSourceFileAction() { TheModule.reset(BEConsumer->takeModule()); } -llvm::Module *CodeGenAction::takeModule() { - return TheModule.take(); -} +llvm::Module *CodeGenAction::takeModule() { return TheModule.release(); } llvm::LLVMContext *CodeGenAction::takeLLVMContext() { OwnsVMContext = false; @@ -497,12 +495,10 @@ ASTConsumer *CodeGenAction::CreateASTConsumer(CompilerInstance &CI, LinkModuleToUse = ModuleOrErr.get(); } - BEConsumer = - new BackendConsumer(BA, CI.getDiagnostics(), - CI.getCodeGenOpts(), CI.getTargetOpts(), - CI.getLangOpts(), - CI.getFrontendOpts().ShowTimers, InFile, - LinkModuleToUse, OS.take(), *VMContext); + BEConsumer = new BackendConsumer(BA, CI.getDiagnostics(), CI.getCodeGenOpts(), + CI.getTargetOpts(), CI.getLangOpts(), + CI.getFrontendOpts().ShowTimers, InFile, + LinkModuleToUse, OS.release(), *VMContext); return BEConsumer; } diff --git a/clang/lib/CodeGen/ModuleBuilder.cpp b/clang/lib/CodeGen/ModuleBuilder.cpp index 920b860..a51abf0 100644 --- a/clang/lib/CodeGen/ModuleBuilder.cpp +++ b/clang/lib/CodeGen/ModuleBuilder.cpp @@ -48,9 +48,7 @@ namespace { return M.get(); } - virtual llvm::Module* ReleaseModule() { - return M.take(); - } + virtual llvm::Module *ReleaseModule() { return M.release(); } virtual void Initialize(ASTContext &Context) { Ctx = &Context; diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 382f8af..bfe332b 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -1215,7 +1215,7 @@ void Driver::BuildActions(const ToolChain &TC, DerivedArgList &Args, // Queue linker inputs. if (Phase == phases::Link) { assert((i + 1) == e && "linking must be final compilation step."); - LinkerInputs.push_back(Current.take()); + LinkerInputs.push_back(Current.release()); break; } @@ -1226,14 +1226,14 @@ void Driver::BuildActions(const ToolChain &TC, DerivedArgList &Args, continue; // Otherwise construct the appropriate action. - Current.reset(ConstructPhaseAction(Args, Phase, Current.take())); + Current.reset(ConstructPhaseAction(Args, Phase, Current.release())); if (Current->getType() == types::TY_Nothing) break; } // If we ended with something, add to the output list. if (Current) - Actions.push_back(Current.take()); + Actions.push_back(Current.release()); } // Add a link action if necessary. diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index d7f9cf5..b7de63f 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -128,7 +128,7 @@ public: Parser.CurrentLines = &Parser.PreprocessorDirectives; else if (!Parser.Line->Tokens.empty()) Parser.CurrentLines = &Parser.Line->Tokens.back().Children; - PreBlockLine = Parser.Line.take(); + PreBlockLine = Parser.Line.release(); Parser.Line.reset(new UnwrappedLine()); Parser.Line->Level = PreBlockLine->Level; Parser.Line->InPPDirective = PreBlockLine->InPPDirective; diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp index cbdfa33..ace3e9c 100644 --- a/clang/lib/Frontend/ASTUnit.cpp +++ b/clang/lib/Frontend/ASTUnit.cpp @@ -781,7 +781,7 @@ ASTUnit *ASTUnit::LoadFromASTFile(const std::string &Filename, // Tell the diagnostic client that we have started a source file. AST->getDiagnostics().getClient()->BeginSourceFile(Context.getLangOpts(),&PP); - return AST.take(); + return AST.release(); } namespace { @@ -1798,7 +1798,7 @@ ASTUnit *ASTUnit::create(CompilerInvocation *CI, AST->SourceMgr = new SourceManager(AST->getDiagnostics(), *AST->FileMgr, UserFilesAreVolatile); - return AST.take(); + return AST.release(); } ASTUnit *ASTUnit::LoadFromCompilerInvocationAction(CompilerInvocation *CI, @@ -1938,7 +1938,7 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction(CompilerInvocation *CI, Act->EndSourceFile(); if (OwnAST) - return OwnAST.take(); + return OwnAST.release(); else return AST; } @@ -2001,7 +2001,8 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocation(CompilerInvocation *CI, llvm::CrashRecoveryContextReleaseRefCleanup > DiagCleanup(Diags.getPtr()); - return AST->LoadFromCompilerInvocation(PrecompilePreamble)? 0 : AST.take(); + return AST->LoadFromCompilerInvocation(PrecompilePreamble) ? 0 + : AST.release(); } ASTUnit *ASTUnit::LoadFromCommandLine(const char **ArgBegin, @@ -2093,7 +2094,7 @@ ASTUnit *ASTUnit::LoadFromCommandLine(const char **ArgBegin, return 0; } - return AST.take(); + return AST.release(); } bool ASTUnit::Reparse(ArrayRef RemappedFiles) { diff --git a/clang/lib/Frontend/ChainedIncludesSource.cpp b/clang/lib/Frontend/ChainedIncludesSource.cpp index 1bdd48e..04753ee 100644 --- a/clang/lib/Frontend/ChainedIncludesSource.cpp +++ b/clang/lib/Frontend/ChainedIncludesSource.cpp @@ -44,7 +44,7 @@ static ASTReader *createASTReader(CompilerInstance &CI, case ASTReader::Success: // Set the predefines buffer as suggested by the PCH reader. PP.setPredefines(Reader->getSuggestedPredefines()); - return Reader.take(); + return Reader.release(); case ASTReader::Failure: case ASTReader::Missing: @@ -98,7 +98,7 @@ ChainedIncludesSource::create(CompilerInstance &CI) { new DiagnosticsEngine(DiagID, &CI.getDiagnosticOpts(), DiagClient)); OwningPtr Clang(new CompilerInstance()); - Clang->setInvocation(CInvok.take()); + Clang->setInvocation(CInvok.release()); Clang->setDiagnostics(Diags.getPtr()); Clang->setTarget(TargetInfo::CreateTargetInfo(Clang->getDiagnostics(), &Clang->getTargetOpts())); @@ -116,7 +116,7 @@ ChainedIncludesSource::create(CompilerInstance &CI) { /*isysroot=*/"", &OS)); Clang->getASTContext().setASTMutationListener( consumer->GetASTMutationListener()); - Clang->setASTConsumer(consumer.take()); + Clang->setASTConsumer(consumer.release()); Clang->createSema(TU_Prefix, 0); if (firstInclude) { @@ -156,7 +156,7 @@ ChainedIncludesSource::create(CompilerInstance &CI) { serialBufs.push_back( llvm::MemoryBuffer::getMemBufferCopy(StringRef(serialAST.data(), serialAST.size()))); - source->CIs.push_back(Clang.take()); + source->CIs.push_back(Clang.release()); } assert(!serialBufs.empty()); diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index be1a540..086d96f 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -156,11 +156,10 @@ static void SetupSerializedDiagnostics(DiagnosticOptions *DiagOpts, << OutputFile << ErrorInfo; return; } - + DiagnosticConsumer *SerializedConsumer = - clang::serialized_diags::create(OS.take(), DiagOpts); + clang::serialized_diags::create(OS.release(), DiagOpts); - Diags.setClient(new ChainedDiagnosticConsumer(Diags.takeClient(), SerializedConsumer)); } @@ -355,7 +354,7 @@ CompilerInstance::createPCHExternalASTSource(StringRef Path, // Set the predefines buffer as suggested by the PCH reader. Typically, the // predefines buffer will be empty. PP.setPredefines(Reader->getSuggestedPredefines()); - return Reader.take(); + return Reader.release(); case ASTReader::Failure: // Unrecoverable failure: don't even try to process the input file. @@ -607,7 +606,7 @@ CompilerInstance::createOutputFile(StringRef OutputPath, if (TempPathName) *TempPathName = TempFile; - return OS.take(); + return OS.release(); } // Initialization Utilities @@ -671,7 +670,7 @@ bool CompilerInstance::InitializeSourceManager(const FrontendInputFile &Input, const FileEntry *File = FileMgr.getVirtualFile(SB->getBufferIdentifier(), SB->getBufferSize(), 0); SourceMgr.createMainFileID(File, Kind); - SourceMgr.overrideFileContents(File, SB.take()); + SourceMgr.overrideFileContents(File, SB.release()); } assert(!SourceMgr.getMainFileID().isInvalid() && diff --git a/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp b/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp index 78f39d4..62a89fa 100644 --- a/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp +++ b/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp @@ -85,5 +85,5 @@ clang::createInvocationFromCommandLine(ArrayRef ArgList, CCArgs.size(), *Diags)) return 0; - return CI.take(); + return CI.release(); } diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index 6cebead..f61b3ba 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -227,7 +227,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, } IntrusiveRefCntPtr FS = - vfs::getVFSFromYAML(Buffer.take(), /*DiagHandler*/0); + vfs::getVFSFromYAML(Buffer.release(), /*DiagHandler*/ 0); if (!FS.getPtr()) { CI.getDiagnostics().Report(diag::err_invalid_vfs_overlay) << *I; goto failure; @@ -343,7 +343,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, goto failure; } - CI.setASTConsumer(Consumer.take()); + CI.setASTConsumer(Consumer.release()); if (!CI.hasASTConsumer()) goto failure; } diff --git a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp index 4c2ec44..540e8b6 100644 --- a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -75,7 +75,7 @@ static FrontendAction *CreateFrontendBaseAction(CompilerInstance &CI) { OwningPtr P(it->instantiate()); if (!P->ParseArgs(CI, CI.getFrontendOpts().PluginArgs)) return 0; - return P.take(); + return P.release(); } } @@ -238,6 +238,6 @@ bool clang::ExecuteCompilerInvocation(CompilerInstance *Clang) { return false; bool Success = Clang->ExecuteAction(*Act); if (Clang->getFrontendOpts().DisableFree) - BuryPointer(Act.take()); + BuryPointer(Act.release()); return Success; } diff --git a/clang/lib/Lex/HeaderMap.cpp b/clang/lib/Lex/HeaderMap.cpp index 0432e09..56fd694 100644 --- a/clang/lib/Lex/HeaderMap.cpp +++ b/clang/lib/Lex/HeaderMap.cpp @@ -103,7 +103,7 @@ const HeaderMap *HeaderMap::Create(const FileEntry *FE, FileManager &FM) { if (Header->Reserved != 0) return 0; // Okay, everything looks good, create the header map. - return new HeaderMap(FileBuffer.take(), NeedsByteSwap); + return new HeaderMap(FileBuffer.release(), NeedsByteSwap); } HeaderMap::~HeaderMap() { diff --git a/clang/lib/Lex/PPLexerChange.cpp b/clang/lib/Lex/PPLexerChange.cpp index 218c5d4..80f863d 100644 --- a/clang/lib/Lex/PPLexerChange.cpp +++ b/clang/lib/Lex/PPLexerChange.cpp @@ -524,7 +524,7 @@ bool Preprocessor::HandleEndOfTokenLexer(Token &Result) { if (NumCachedTokenLexers == TokenLexerCacheSize) CurTokenLexer.reset(); else - TokenLexerCache[NumCachedTokenLexers++] = CurTokenLexer.take(); + TokenLexerCache[NumCachedTokenLexers++] = CurTokenLexer.release(); // Handle this like a #include file being popped off the stack. return HandleEndOfFile(Result, true); @@ -541,7 +541,7 @@ void Preprocessor::RemoveTopOfLexerStack() { if (NumCachedTokenLexers == TokenLexerCacheSize) CurTokenLexer.reset(); else - TokenLexerCache[NumCachedTokenLexers++] = CurTokenLexer.take(); + TokenLexerCache[NumCachedTokenLexers++] = CurTokenLexer.release(); } PopIncludeMacroStack(); diff --git a/clang/lib/Lex/PTHLexer.cpp b/clang/lib/Lex/PTHLexer.cpp index dd8363d..c962409 100644 --- a/clang/lib/Lex/PTHLexer.cpp +++ b/clang/lib/Lex/PTHLexer.cpp @@ -534,9 +534,9 @@ PTHManager *PTHManager::Create(const std::string &file, if (!len) originalSourceBase = 0; // Create the new PTHManager. - return new PTHManager(File.take(), FL.take(), IData, PerIDCache, - SL.take(), NumIds, spellingBase, - (const char*) originalSourceBase); + return new PTHManager(File.release(), FL.release(), IData, PerIDCache, + SL.release(), NumIds, spellingBase, + (const char *)originalSourceBase); } IdentifierInfo* PTHManager::LazilyCreateIdentifierInfo(unsigned PersistentID) { diff --git a/clang/lib/Serialization/GlobalModuleIndex.cpp b/clang/lib/Serialization/GlobalModuleIndex.cpp index fcdf5f5..e46cb97 100644 --- a/clang/lib/Serialization/GlobalModuleIndex.cpp +++ b/clang/lib/Serialization/GlobalModuleIndex.cpp @@ -247,8 +247,9 @@ GlobalModuleIndex::readIndex(StringRef Path) { Cursor.Read(8) != 'I') { return std::make_pair((GlobalModuleIndex *)0, EC_IOError); } - - return std::make_pair(new GlobalModuleIndex(Buffer.take(), Cursor), EC_None); + + return std::make_pair(new GlobalModuleIndex(Buffer.release(), Cursor), + EC_None); } void diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp index c07596f..176826d 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -3465,7 +3465,7 @@ void BugReporter::FlushReport(BugReport *exampleReport, D->addMeta(*i); } - PD.HandlePathDiagnostic(D.take()); + PD.HandlePathDiagnostic(D.release()); } void BugReporter::EmitBasicReport(const Decl *DeclWithIssue, diff --git a/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp b/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp index e0fafef..8c08e75 100644 --- a/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp +++ b/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp @@ -275,8 +275,8 @@ void PathDiagnosticConsumer::HandlePathDiagnostic(PathDiagnostic *D) { Diags.RemoveNode(orig); delete orig; } - - Diags.InsertNode(OwningD.take()); + + Diags.InsertNode(OwningD.release()); } static Optional comparePath(const PathPieces &X, const PathPieces &Y); diff --git a/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp b/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp index d8feac3..e3977c2 100644 --- a/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ b/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -730,7 +730,7 @@ static ExplodedNode::Auditor* CreateUbiViz() { OwningPtr Stream; Stream.reset(new llvm::raw_fd_ostream(FD, true)); - return new UbigraphViz(Stream.take(), P); + return new UbigraphViz(Stream.release(), P); } void UbigraphViz::AddEdge(ExplodedNode *Src, ExplodedNode *Dst) { diff --git a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp index e7def08..d7cb914 100644 --- a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp +++ b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp @@ -123,7 +123,7 @@ CheckerManager *ento::createCheckerManager(AnalyzerOptions &opts, << checkerOpts[i].getName(); } - return checkerMgr.take(); + return checkerMgr.release(); } void ento::printCheckerHelp(raw_ostream &out, ArrayRef plugins) { diff --git a/clang/lib/Tooling/JSONCompilationDatabase.cpp b/clang/lib/Tooling/JSONCompilationDatabase.cpp index dad4600..232c329 100644 --- a/clang/lib/Tooling/JSONCompilationDatabase.cpp +++ b/clang/lib/Tooling/JSONCompilationDatabase.cpp @@ -126,7 +126,7 @@ class JSONCompilationDatabasePlugin : public CompilationDatabasePlugin { JSONCompilationDatabase::loadFromFile(JSONDatabasePath, ErrorMessage)); if (!Database) return NULL; - return Database.take(); + return Database.release(); } }; @@ -152,10 +152,10 @@ JSONCompilationDatabase::loadFromFile(StringRef FilePath, return NULL; } OwningPtr Database( - new JSONCompilationDatabase(DatabaseBuffer.take())); + new JSONCompilationDatabase(DatabaseBuffer.release())); if (!Database->parse(ErrorMessage)) return NULL; - return Database.take(); + return Database.release(); } JSONCompilationDatabase * @@ -164,10 +164,10 @@ JSONCompilationDatabase::loadFromBuffer(StringRef DatabaseString, OwningPtr DatabaseBuffer( llvm::MemoryBuffer::getMemBuffer(DatabaseString)); OwningPtr Database( - new JSONCompilationDatabase(DatabaseBuffer.take())); + new JSONCompilationDatabase(DatabaseBuffer.release())); if (!Database->parse(ErrorMessage)) return NULL; - return Database.take(); + return Database.release(); } std::vector diff --git a/clang/lib/Tooling/Tooling.cpp b/clang/lib/Tooling/Tooling.cpp index ee110e3..9783ed0 100644 --- a/clang/lib/Tooling/Tooling.cpp +++ b/clang/lib/Tooling/Tooling.cpp @@ -228,7 +228,7 @@ bool ToolInvocation::run() { llvm::MemoryBuffer::getMemBuffer(It->getValue()); Invocation->getPreprocessorOpts().addRemappedFile(It->getKey(), Input); } - return runInvocation(BinaryName, Compilation.get(), Invocation.take()); + return runInvocation(BinaryName, Compilation.get(), Invocation.release()); } bool ToolInvocation::runInvocation( diff --git a/clang/tools/driver/cc1_main.cpp b/clang/tools/driver/cc1_main.cpp index 28ada69..8738e0a 100644 --- a/clang/tools/driver/cc1_main.cpp +++ b/clang/tools/driver/cc1_main.cpp @@ -113,7 +113,7 @@ int cc1_main(const char **ArgBegin, const char **ArgEnd, if (Clang->getFrontendOpts().DisableFree) { if (llvm::AreStatisticsEnabled() || Clang->getFrontendOpts().ShowStats) llvm::PrintStatistics(); - BuryPointer(Clang.take()); + BuryPointer(Clang.release()); return !Success; } diff --git a/clang/tools/driver/cc1as_main.cpp b/clang/tools/driver/cc1as_main.cpp index d5b6111..e68bd02 100644 --- a/clang/tools/driver/cc1as_main.cpp +++ b/clang/tools/driver/cc1as_main.cpp @@ -277,7 +277,7 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts, Diags.Report(diag::err_fe_error_reading) << Opts.InputFile; return false; } - MemoryBuffer *Buffer = BufferPtr.take(); + MemoryBuffer *Buffer = BufferPtr.release(); SourceMgr SrcMgr; diff --git a/clang/tools/libclang/ARCMigrate.cpp b/clang/tools/libclang/ARCMigrate.cpp index 3941794..1b80b2f 100644 --- a/clang/tools/libclang/ARCMigrate.cpp +++ b/clang/tools/libclang/ARCMigrate.cpp @@ -70,7 +70,7 @@ CXRemapping clang_getRemappings(const char *migrate_dir_path) { return 0; } - return remap.take(); + return remap.release(); } CXRemapping clang_getRemappingsFromFileList(const char **filePaths, @@ -83,7 +83,7 @@ CXRemapping clang_getRemappingsFromFileList(const char **filePaths, if (Logging) llvm::errs() << "clang_getRemappingsFromFileList was called with " "numFiles=0\n"; - return remap.take(); + return remap.release(); } if (!filePaths) { @@ -108,10 +108,10 @@ CXRemapping clang_getRemappingsFromFileList(const char **filePaths, I = diagBuffer.err_begin(), E = diagBuffer.err_end(); I != E; ++I) llvm::errs() << I->second << '\n'; } - return remap.take(); + return remap.release(); } - return remap.take(); + return remap.release(); } unsigned clang_remap_getNumFiles(CXRemapping map) { diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp index 52a7929..ac66a77 100644 --- a/clang/tools/libclang/CIndex.cpp +++ b/clang/tools/libclang/CIndex.cpp @@ -2811,7 +2811,7 @@ static void clang_parseTranslationUnit_Impl(void *UserData) { if (isASTReadError(Unit ? Unit.get() : ErrUnit.get())) { PTUI->result = CXError_ASTReadError; } else { - *PTUI->out_TU = MakeCXTranslationUnit(CXXIdx, Unit.take()); + *PTUI->out_TU = MakeCXTranslationUnit(CXXIdx, Unit.release()); PTUI->result = *PTUI->out_TU ? CXError_Success : CXError_Failure; } } @@ -6607,7 +6607,7 @@ CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU) { CXTUResourceUsage usage = { (void*) entries.get(), (unsigned) entries->size(), entries->size() ? &(*entries)[0] : 0 }; - entries.take(); + entries.release(); return usage; } diff --git a/clang/tools/libclang/CXLoadedDiagnostic.cpp b/clang/tools/libclang/CXLoadedDiagnostic.cpp index a6a80cd..2871256 100644 --- a/clang/tools/libclang/CXLoadedDiagnostic.cpp +++ b/clang/tools/libclang/CXLoadedDiagnostic.cpp @@ -292,7 +292,7 @@ CXDiagnosticSet DiagLoader::load(const char *file) { BlockID, true); switch (Res) { case Read_EndOfStream: - return (CXDiagnosticSet) Diags.take(); + return (CXDiagnosticSet)Diags.release(); case Read_Failure: return 0; case Read_Record: @@ -567,7 +567,7 @@ LoadResult DiagLoader::readDiagnosticBlock(llvm::BitstreamCursor &Stream, continue; } case Read_BlockEnd: - Diags.appendDiagnostic(D.take()); + Diags.appendDiagnostic(D.release()); return Success; case Read_Record: break; diff --git a/clang/unittests/Sema/ExternalSemaSourceTest.cpp b/clang/unittests/Sema/ExternalSemaSourceTest.cpp index e27d0cd..bc8b211 100644 --- a/clang/unittests/Sema/ExternalSemaSourceTest.cpp +++ b/clang/unittests/Sema/ExternalSemaSourceTest.cpp @@ -184,7 +184,7 @@ TEST(ExternalSemaSource, SanityCheck) { Installer->PushWatcher(&Watcher); std::vector Args(1, "-std=c++11"); ASSERT_TRUE(clang::tooling::runToolOnCodeWithArgs( - Installer.take(), "namespace AAA { } using namespace AAB;", Args)); + Installer.release(), "namespace AAA { } using namespace AAB;", Args)); ASSERT_EQ(0, Watcher.SeenCount); } @@ -199,7 +199,7 @@ TEST(ExternalSemaSource, ExternalTypoCorrectionPrioritized) { Installer->PushWatcher(&Watcher); std::vector Args(1, "-std=c++11"); ASSERT_TRUE(clang::tooling::runToolOnCodeWithArgs( - Installer.take(), "namespace AAA { } using namespace AAB;", Args)); + Installer.release(), "namespace AAA { } using namespace AAB;", Args)); ASSERT_LE(0, Provider.CallCount); ASSERT_EQ(1, Watcher.SeenCount); } @@ -219,7 +219,7 @@ TEST(ExternalSemaSource, ExternalTypoCorrectionOrdering) { Installer->PushWatcher(&Watcher); std::vector Args(1, "-std=c++11"); ASSERT_TRUE(clang::tooling::runToolOnCodeWithArgs( - Installer.take(), "namespace AAA { } using namespace AAB;", Args)); + Installer.release(), "namespace AAA { } using namespace AAB;", Args)); ASSERT_LE(1, First.CallCount); ASSERT_LE(1, Second.CallCount); ASSERT_EQ(0, Third.CallCount); @@ -237,7 +237,7 @@ TEST(ExternalSemaSource, TryOtherTacticsBeforeDiagnosing) { // This code hits the class template specialization/class member of a class // template specialization checks in Sema::RequireCompleteTypeImpl. ASSERT_TRUE(clang::tooling::runToolOnCodeWithArgs( - Installer.take(), + Installer.release(), "template struct S { class C { }; }; S::C SCInst;", Args)); ASSERT_EQ(0, Diagnoser.CallCount); @@ -256,7 +256,7 @@ TEST(ExternalSemaSource, FirstDiagnoserTaken) { Installer->PushSource(&Third); std::vector Args(1, "-std=c++11"); ASSERT_FALSE(clang::tooling::runToolOnCodeWithArgs( - Installer.take(), "class Incomplete; Incomplete IncompleteInstance;", + Installer.release(), "class Incomplete; Incomplete IncompleteInstance;", Args)); ASSERT_EQ(1, First.CallCount); ASSERT_EQ(1, Second.CallCount); -- 2.7.4