From: Benjamin Kramer Date: Sun, 12 Jun 2016 20:05:23 +0000 (+0000) Subject: Add some std::move where the value is only read otherwise. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2a965aedd37df1ad330694cace8b3f2041589715;p=clang Add some std::move where the value is only read otherwise. This mostly affects smart pointers. No functionality change intended. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@272520 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h index 305dba2504..8dcdeb6f84 100644 --- a/include/clang/AST/DeclTemplate.h +++ b/include/clang/AST/DeclTemplate.h @@ -2356,7 +2356,7 @@ public: bool HasExplicitTemplateArgs, TemplateArgumentListInfo TemplateArgs) { return new (C, DC) ClassScopeFunctionSpecializationDecl( - DC, Loc, FD, HasExplicitTemplateArgs, TemplateArgs); + DC, Loc, FD, HasExplicitTemplateArgs, std::move(TemplateArgs)); } static ClassScopeFunctionSpecializationDecl * diff --git a/include/clang/Driver/Driver.h b/include/clang/Driver/Driver.h index 03e6ed0ed3..5eb4d8a79a 100644 --- a/include/clang/Driver/Driver.h +++ b/include/clang/Driver/Driver.h @@ -248,7 +248,7 @@ public: void setCheckInputsExist(bool Value) { CheckInputsExist = Value; } const std::string &getTitle() { return DriverTitle; } - void setTitle(std::string Value) { DriverTitle = Value; } + void setTitle(std::string Value) { DriverTitle = std::move(Value); } /// \brief Get the path to the main clang executable. const char *getClangProgramPath() const { diff --git a/include/clang/Frontend/CompilerInstance.h b/include/clang/Frontend/CompilerInstance.h index 99c43aa40d..cf66088aae 100644 --- a/include/clang/Frontend/CompilerInstance.h +++ b/include/clang/Frontend/CompilerInstance.h @@ -380,7 +380,7 @@ public: /// \note Most clients should use setFileManager, which will implicitly reset /// the virtual file system to the one contained in the file manager. void setVirtualFileSystem(IntrusiveRefCntPtr FS) { - VirtualFileSystem = FS; + VirtualFileSystem = std::move(FS); } /// } diff --git a/include/clang/Frontend/TextDiagnosticPrinter.h b/include/clang/Frontend/TextDiagnosticPrinter.h index 04a570559f..07cee9f8ad 100644 --- a/include/clang/Frontend/TextDiagnosticPrinter.h +++ b/include/clang/Frontend/TextDiagnosticPrinter.h @@ -45,7 +45,7 @@ public: /// setPrefix - Set the diagnostic printer prefix string, which will be /// printed at the start of any diagnostics. If empty, no prefix string is /// used. - void setPrefix(std::string Value) { Prefix = Value; } + void setPrefix(std::string Value) { Prefix = std::move(Value); } void BeginSourceFile(const LangOptions &LO, const Preprocessor *PP) override; void EndSourceFile() override; diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index fa46b24e57..5fc7877322 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -816,7 +816,7 @@ void ASTContext::AddDeallocation(void (*Callback)(void*), void *Data) { void ASTContext::setExternalSource(IntrusiveRefCntPtr Source) { - ExternalSource = Source; + ExternalSource = std::move(Source); } void ASTContext::PrintStats() const { diff --git a/lib/Basic/VirtualFileSystem.cpp b/lib/Basic/VirtualFileSystem.cpp index d64c4e3d8c..2eb7a84521 100644 --- a/lib/Basic/VirtualFileSystem.cpp +++ b/lib/Basic/VirtualFileSystem.cpp @@ -280,7 +280,7 @@ directory_iterator RealFileSystem::dir_begin(const Twine &Dir, // OverlayFileSystem implementation //===-----------------------------------------------------------------------===/ OverlayFileSystem::OverlayFileSystem(IntrusiveRefCntPtr BaseFS) { - FSList.push_back(BaseFS); + FSList.push_back(std::move(BaseFS)); } void OverlayFileSystem::pushOverlay(IntrusiveRefCntPtr FS) { @@ -1395,7 +1395,7 @@ RedirectingFileSystem::create(std::unique_ptr Buffer, RedirectingFileSystemParser P(Stream); std::unique_ptr FS( - new RedirectingFileSystem(ExternalFS)); + new RedirectingFileSystem(std::move(ExternalFS))); if (!YAMLFilePath.empty()) { // Use the YAML path from -ivfsoverlay to compute the dir to be prefixed @@ -1576,7 +1576,8 @@ vfs::getVFSFromYAML(std::unique_ptr Buffer, void *DiagContext, IntrusiveRefCntPtr ExternalFS) { return RedirectingFileSystem::create(std::move(Buffer), DiagHandler, - YAMLFilePath, DiagContext, ExternalFS); + YAMLFilePath, DiagContext, + std::move(ExternalFS)); } UniqueID vfs::getNextVirtualUniqueID() { diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp index 71a76a45ba..635d566159 100644 --- a/lib/Frontend/ASTUnit.cpp +++ b/lib/Frontend/ASTUnit.cpp @@ -1040,7 +1040,7 @@ bool ASTUnit::Parse(std::shared_ptr PCHContainerOps, // Create the compiler instance to use for building the AST. std::unique_ptr Clang( - new CompilerInstance(PCHContainerOps)); + new CompilerInstance(std::move(PCHContainerOps))); // Recover resources if we crash before exiting this method. llvm::CrashRecoveryContextCleanupRegistrar @@ -1514,7 +1514,7 @@ ASTUnit::getMainBufferWithPrecompiledPreamble( // Create the compiler instance to use for building the precompiled preamble. std::unique_ptr Clang( - new CompilerInstance(PCHContainerOps)); + new CompilerInstance(std::move(PCHContainerOps))); // Recover resources if we crash before exiting this method. llvm::CrashRecoveryContextCleanupRegistrar @@ -1776,7 +1776,7 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction( // Create the compiler instance to use for building the AST. std::unique_ptr Clang( - new CompilerInstance(PCHContainerOps)); + new CompilerInstance(std::move(PCHContainerOps))); // Recover resources if we crash before exiting this method. llvm::CrashRecoveryContextCleanupRegistrar @@ -1896,7 +1896,7 @@ bool ASTUnit::LoadFromCompilerInvocation( llvm::CrashRecoveryContextCleanupRegistrar MemBufferCleanup(OverrideMainBuffer.get()); - return Parse(PCHContainerOps, std::move(OverrideMainBuffer)); + return Parse(std::move(PCHContainerOps), std::move(OverrideMainBuffer)); } std::unique_ptr ASTUnit::LoadFromCompilerInvocation( @@ -1929,7 +1929,7 @@ std::unique_ptr ASTUnit::LoadFromCompilerInvocation( llvm::CrashRecoveryContextReleaseRefCleanup > DiagCleanup(Diags.get()); - if (AST->LoadFromCompilerInvocation(PCHContainerOps, + if (AST->LoadFromCompilerInvocation(std::move(PCHContainerOps), PrecompilePreambleAfterNParses)) return nullptr; return AST; @@ -2012,7 +2012,7 @@ ASTUnit *ASTUnit::LoadFromCommandLine( llvm::CrashRecoveryContextCleanupRegistrar ASTUnitCleanup(AST.get()); - if (AST->LoadFromCompilerInvocation(PCHContainerOps, + if (AST->LoadFromCompilerInvocation(std::move(PCHContainerOps), PrecompilePreambleAfterNParses)) { // Some error occurred, if caller wants to examine diagnostics, pass it the // ASTUnit. @@ -2062,7 +2062,8 @@ bool ASTUnit::Reparse(std::shared_ptr PCHContainerOps, getDiagnostics().setNumWarnings(NumWarningsInPreamble); // Parse the sources - bool Result = Parse(PCHContainerOps, std::move(OverrideMainBuffer)); + bool Result = + Parse(std::move(PCHContainerOps), std::move(OverrideMainBuffer)); // If we're caching global code-completion results, and the top-level // declarations have changed, clear out the code-completion cache. diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp index 64f571e17a..d89d933fe2 100644 --- a/lib/Frontend/CompilerInstance.cpp +++ b/lib/Frontend/CompilerInstance.cpp @@ -127,7 +127,7 @@ IntrusiveRefCntPtr CompilerInstance::getModuleManager() const { return ModuleManager; } void CompilerInstance::setModuleManager(IntrusiveRefCntPtr Reader) { - ModuleManager = Reader; + ModuleManager = std::move(Reader); } std::shared_ptr @@ -137,7 +137,7 @@ CompilerInstance::getModuleDepCollector() const { void CompilerInstance::setModuleDepCollector( std::shared_ptr Collector) { - ModuleDepCollector = Collector; + ModuleDepCollector = std::move(Collector); } // Diagnostics diff --git a/lib/Tooling/Tooling.cpp b/lib/Tooling/Tooling.cpp index 69a4611e64..c8ebc0348f 100644 --- a/lib/Tooling/Tooling.cpp +++ b/lib/Tooling/Tooling.cpp @@ -104,7 +104,8 @@ bool runToolOnCode(clang::FrontendAction *ToolAction, const Twine &Code, const Twine &FileName, std::shared_ptr PCHContainerOps) { return runToolOnCodeWithArgs(ToolAction, Code, std::vector(), - FileName, "clang-tool", PCHContainerOps); + FileName, "clang-tool", + std::move(PCHContainerOps)); } static std::vector @@ -136,7 +137,8 @@ bool runToolOnCodeWithArgs( llvm::IntrusiveRefCntPtr Files( new FileManager(FileSystemOptions(), OverlayFileSystem)); ToolInvocation Invocation(getSyntaxOnlyToolArgs(ToolName, Args, FileNameRef), - ToolAction, Files.get(), PCHContainerOps); + ToolAction, Files.get(), + std::move(PCHContainerOps)); SmallString<1024> CodeStorage; InMemoryFileSystem->addFile(FileNameRef, 0, @@ -265,7 +267,7 @@ bool ToolInvocation::run() { Input.release()); } return runInvocation(BinaryName, Compilation.get(), Invocation.release(), - PCHContainerOps); + std::move(PCHContainerOps)); } bool ToolInvocation::runInvocation( @@ -279,7 +281,7 @@ bool ToolInvocation::runInvocation( llvm::errs() << "\n"; } - return Action->runInvocation(Invocation, Files, PCHContainerOps, + return Action->runInvocation(Invocation, Files, std::move(PCHContainerOps), DiagConsumer); } @@ -288,7 +290,7 @@ bool FrontendActionFactory::runInvocation( std::shared_ptr PCHContainerOps, DiagnosticConsumer *DiagConsumer) { // Create a compiler instance to handle the actual work. - clang::CompilerInstance Compiler(PCHContainerOps); + clang::CompilerInstance Compiler(std::move(PCHContainerOps)); Compiler.setInvocation(Invocation); Compiler.setFileManager(Files); @@ -332,9 +334,10 @@ void ClangTool::mapVirtualFile(StringRef FilePath, StringRef Content) { void ClangTool::appendArgumentsAdjuster(ArgumentsAdjuster Adjuster) { if (ArgsAdjuster) - ArgsAdjuster = combineAdjusters(ArgsAdjuster, Adjuster); + ArgsAdjuster = + combineAdjusters(std::move(ArgsAdjuster), std::move(Adjuster)); else - ArgsAdjuster = Adjuster; + ArgsAdjuster = std::move(Adjuster); } void ClangTool::clearArgumentsAdjusters() { @@ -466,7 +469,7 @@ public: std::shared_ptr PCHContainerOps, DiagnosticConsumer *DiagConsumer) override { std::unique_ptr AST = ASTUnit::LoadFromCompilerInvocation( - Invocation, PCHContainerOps, + Invocation, std::move(PCHContainerOps), CompilerInstance::createDiagnostics(&Invocation->getDiagnosticOpts(), DiagConsumer, /*ShouldOwnClient=*/false), @@ -490,7 +493,7 @@ std::unique_ptr buildASTFromCode(const Twine &Code, const Twine &FileName, std::shared_ptr PCHContainerOps) { return buildASTFromCodeWithArgs(Code, std::vector(), FileName, - "clang-tool", PCHContainerOps); + "clang-tool", std::move(PCHContainerOps)); } std::unique_ptr buildASTFromCodeWithArgs( @@ -510,7 +513,7 @@ std::unique_ptr buildASTFromCodeWithArgs( llvm::IntrusiveRefCntPtr Files( new FileManager(FileSystemOptions(), OverlayFileSystem)); ToolInvocation Invocation(getSyntaxOnlyToolArgs(ToolName, Args, FileNameRef), - &Action, Files.get(), PCHContainerOps); + &Action, Files.get(), std::move(PCHContainerOps)); SmallString<1024> CodeStorage; InMemoryFileSystem->addFile(FileNameRef, 0,