From 5c3181a1ffc2fb42e8e7a83875298db981480651 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Thu, 11 Sep 2014 14:13:49 +0000 Subject: [PATCH] Avoid some unnecessary SmallVector copies. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217586 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/ASTMatchers/ASTMatchFinder.h | 2 +- lib/CodeGen/MicrosoftCXXABI.cpp | 2 +- lib/Driver/Driver.cpp | 2 +- lib/Driver/Tools.cpp | 4 ++-- .../Checkers/SimpleStreamChecker.cpp | 14 ++++++-------- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/include/clang/ASTMatchers/ASTMatchFinder.h b/include/clang/ASTMatchers/ASTMatchFinder.h index dfd414f35b..bdc15a0d81 100644 --- a/include/clang/ASTMatchers/ASTMatchFinder.h +++ b/include/clang/ASTMatchers/ASTMatchFinder.h @@ -253,7 +253,7 @@ match(MatcherT Matcher, const ast_type_traits::DynTypedNode &Node, MatchFinder Finder; Finder.addMatcher(Matcher, &Callback); Finder.match(Node, Context); - return Callback.Nodes; + return std::move(Callback.Nodes); } template diff --git a/lib/CodeGen/MicrosoftCXXABI.cpp b/lib/CodeGen/MicrosoftCXXABI.cpp index b3074def40..e308a15ef1 100644 --- a/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/lib/CodeGen/MicrosoftCXXABI.cpp @@ -1162,7 +1162,7 @@ void MicrosoftCXXABI::EmitDestructorCall(CodeGenFunction &CGF, void MicrosoftCXXABI::emitVTableDefinitions(CodeGenVTables &CGVT, const CXXRecordDecl *RD) { MicrosoftVTableContext &VFTContext = CGM.getMicrosoftVTableContext(); - VPtrInfoVector VFPtrs = VFTContext.getVFPtrOffsets(RD); + const VPtrInfoVector &VFPtrs = VFTContext.getVFPtrOffsets(RD); for (VPtrInfo *Info : VFPtrs) { llvm::GlobalVariable *VTable = getAddrOfVTable(RD, Info->FullOffsetInMDC); diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index 647d2ca2b3..8b159f054a 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -518,7 +518,7 @@ void Driver::generateCompilationDiagnostics(Compilation &C, << "\n********************\n\n" "PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\n" "Preprocessed source(s) and associated run script(s) are located at:"; - ArgStringList Files = C.getTempFiles(); + const ArgStringList &Files = C.getTempFiles(); for (ArgStringList::const_iterator it = Files.begin(), ie = Files.end(); it != ie; ++it) { Diag(clang::diag::note_drv_command_failed_diag_msg) << *it; diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 559f30e89f..36d5a54750 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -6599,7 +6599,7 @@ void freebsd::Link::ConstructJob(Compilation &C, const JobAction &JA, } Args.AddAllArgs(CmdArgs, options::OPT_L); - const ToolChain::path_list Paths = ToolChain.getFilePaths(); + const ToolChain::path_list &Paths = ToolChain.getFilePaths(); for (const auto &Path : Paths) CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + Path)); Args.AddAllArgs(CmdArgs, options::OPT_T_Group); @@ -7425,7 +7425,7 @@ void gnutools::Link::ConstructJob(Compilation &C, const JobAction &JA, Args.AddAllArgs(CmdArgs, options::OPT_L); Args.AddAllArgs(CmdArgs, options::OPT_u); - const ToolChain::path_list Paths = ToolChain.getFilePaths(); + const ToolChain::path_list &Paths = ToolChain.getFilePaths(); for (const auto &Path : Paths) CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + Path)); diff --git a/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp b/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp index 3e9b57bdc5..ccf816c80c 100644 --- a/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp @@ -63,8 +63,7 @@ class SimpleStreamChecker : public Checker LeakedStreams, CheckerContext &C, ExplodedNode *ErrNode) const; bool guaranteedNotToCloseFile(const CallEvent &Call) const; @@ -222,16 +221,15 @@ void SimpleStreamChecker::reportDoubleClose(SymbolRef FileDescSym, C.emitReport(R); } -void SimpleStreamChecker::reportLeaks(SymbolVector LeakedStreams, - CheckerContext &C, - ExplodedNode *ErrNode) const { +void SimpleStreamChecker::reportLeaks(ArrayRef LeakedStreams, + CheckerContext &C, + ExplodedNode *ErrNode) const { // Attach bug reports to the leak node. // TODO: Identify the leaked file descriptor. - for (SmallVectorImpl::iterator - I = LeakedStreams.begin(), E = LeakedStreams.end(); I != E; ++I) { + for (SymbolRef LeakedStream : LeakedStreams) { BugReport *R = new BugReport(*LeakBugType, "Opened file is never closed; potential resource leak", ErrNode); - R->markInteresting(*I); + R->markInteresting(LeakedStream); C.emitReport(R); } } -- 2.40.0