<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 11, 2014 at 7:13 AM, Benjamin Kramer <span dir="ltr"><<a href="mailto:benny.kra@googlemail.com" target="_blank">benny.kra@googlemail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: d0k<br>
Date: Thu Sep 11 09:13:49 2014<br>
New Revision: 217586<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=217586&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=217586&view=rev</a><br>
Log:<br>
Avoid some unnecessary SmallVector copies.<br></blockquote><div><br></div><div>What technique did you use to find these cases?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
No functionality change.<br>
<br>
Modified:<br>
cfe/trunk/include/clang/ASTMatchers/ASTMatchFinder.h<br>
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp<br>
cfe/trunk/lib/Driver/Driver.cpp<br>
cfe/trunk/lib/Driver/Tools.cpp<br>
cfe/trunk/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp<br>
<br>
Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchFinder.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchFinder.h?rev=217586&r1=217585&r2=217586&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchFinder.h?rev=217586&r1=217585&r2=217586&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchFinder.h (original)<br>
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchFinder.h Thu Sep 11 09:13:49 2014<br>
@@ -253,7 +253,7 @@ match(MatcherT Matcher, const ast_type_t<br>
MatchFinder Finder;<br>
Finder.addMatcher(Matcher, &Callback);<br>
Finder.match(Node, Context);<br>
- return Callback.Nodes;<br>
+ return std::move(Callback.Nodes);<br>
}<br>
<br>
template <typename MatcherT, typename NodeT><br>
<br>
Modified: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=217586&r1=217585&r2=217586&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=217586&r1=217585&r2=217586&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Thu Sep 11 09:13:49 2014<br>
@@ -1162,7 +1162,7 @@ void MicrosoftCXXABI::EmitDestructorCall<br>
void MicrosoftCXXABI::emitVTableDefinitions(CodeGenVTables &CGVT,<br>
const CXXRecordDecl *RD) {<br>
MicrosoftVTableContext &VFTContext = CGM.getMicrosoftVTableContext();<br>
- VPtrInfoVector VFPtrs = VFTContext.getVFPtrOffsets(RD);<br>
+ const VPtrInfoVector &VFPtrs = VFTContext.getVFPtrOffsets(RD);<br>
<br>
for (VPtrInfo *Info : VFPtrs) {<br>
llvm::GlobalVariable *VTable = getAddrOfVTable(RD, Info->FullOffsetInMDC);<br>
<br>
Modified: cfe/trunk/lib/Driver/Driver.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=217586&r1=217585&r2=217586&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=217586&r1=217585&r2=217586&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Driver/Driver.cpp (original)<br>
+++ cfe/trunk/lib/Driver/Driver.cpp Thu Sep 11 09:13:49 2014<br>
@@ -518,7 +518,7 @@ void Driver::generateCompilationDiagnost<br>
<< "\n********************\n\n"<br>
"PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\n"<br>
"Preprocessed source(s) and associated run script(s) are located at:";<br>
- ArgStringList Files = C.getTempFiles();<br>
+ const ArgStringList &Files = C.getTempFiles();<br>
for (ArgStringList::const_iterator it = Files.begin(), ie = Files.end();<br>
it != ie; ++it) {<br>
Diag(clang::diag::note_drv_command_failed_diag_msg) << *it;<br>
<br>
Modified: cfe/trunk/lib/Driver/Tools.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=217586&r1=217585&r2=217586&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=217586&r1=217585&r2=217586&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Driver/Tools.cpp (original)<br>
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Sep 11 09:13:49 2014<br>
@@ -6599,7 +6599,7 @@ void freebsd::Link::ConstructJob(Compila<br>
}<br>
<br>
Args.AddAllArgs(CmdArgs, options::OPT_L);<br>
- const ToolChain::path_list Paths = ToolChain.getFilePaths();<br>
+ const ToolChain::path_list &Paths = ToolChain.getFilePaths();<br>
for (const auto &Path : Paths)<br>
CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + Path));<br>
Args.AddAllArgs(CmdArgs, options::OPT_T_Group);<br>
@@ -7425,7 +7425,7 @@ void gnutools::Link::ConstructJob(Compil<br>
Args.AddAllArgs(CmdArgs, options::OPT_L);<br>
Args.AddAllArgs(CmdArgs, options::OPT_u);<br>
<br>
- const ToolChain::path_list Paths = ToolChain.getFilePaths();<br>
+ const ToolChain::path_list &Paths = ToolChain.getFilePaths();<br>
<br>
for (const auto &Path : Paths)<br>
CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + Path));<br>
<br>
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp?rev=217586&r1=217585&r2=217586&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp?rev=217586&r1=217585&r2=217586&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp (original)<br>
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp Thu Sep 11 09:13:49 2014<br>
@@ -63,8 +63,7 @@ class SimpleStreamChecker : public Check<br>
const CallEvent &Call,<br>
CheckerContext &C) const;<br>
<br>
- void reportLeaks(SymbolVector LeakedStreams,<br>
- CheckerContext &C,<br>
+ void reportLeaks(ArrayRef<SymbolRef> LeakedStreams, CheckerContext &C,<br>
ExplodedNode *ErrNode) const;<br>
<br>
bool guaranteedNotToCloseFile(const CallEvent &Call) const;<br>
@@ -222,16 +221,15 @@ void SimpleStreamChecker::reportDoubleCl<br>
C.emitReport(R);<br>
}<br>
<br>
-void SimpleStreamChecker::reportLeaks(SymbolVector LeakedStreams,<br>
- CheckerContext &C,<br>
- ExplodedNode *ErrNode) const {<br>
+void SimpleStreamChecker::reportLeaks(ArrayRef<SymbolRef> LeakedStreams,<br>
+ CheckerContext &C,<br>
+ ExplodedNode *ErrNode) const {<br>
// Attach bug reports to the leak node.<br>
// TODO: Identify the leaked file descriptor.<br>
- for (SmallVectorImpl<SymbolRef>::iterator<br>
- I = LeakedStreams.begin(), E = LeakedStreams.end(); I != E; ++I) {<br>
+ for (SymbolRef LeakedStream : LeakedStreams) {<br>
BugReport *R = new BugReport(*LeakBugType,<br>
"Opened file is never closed; potential resource leak", ErrNode);<br>
- R->markInteresting(*I);<br>
+ R->markInteresting(LeakedStream);<br>
C.emitReport(R);<br>
}<br>
}<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>