r203477 - [C++11] Avoid implicit conversion of ArrayRef to std::vector and use move semantics where appropriate.
Benjamin Kramer
benny.kra at googlemail.com
Mon Mar 10 10:55:03 PDT 2014
Author: d0k
Date: Mon Mar 10 12:55:02 2014
New Revision: 203477
URL: http://llvm.org/viewvc/llvm-project?rev=203477&view=rev
Log:
[C++11] Avoid implicit conversion of ArrayRef to std::vector and use move semantics where appropriate.
Modified:
cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h
cfe/trunk/include/clang/Tooling/CompilationDatabase.h
cfe/trunk/lib/ASTMatchers/Dynamic/Marshallers.h
cfe/trunk/lib/ASTMatchers/Dynamic/VariantValue.cpp
cfe/trunk/lib/Basic/VirtualFileSystem.cpp
cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
cfe/trunk/lib/Tooling/CompilationDatabase.cpp
Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h?rev=203477&r1=203476&r2=203477&view=diff
==============================================================================
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h Mon Mar 10 12:55:02 2014
@@ -1106,8 +1106,8 @@ template <typename T>
class VariadicOperatorMatcherInterface : public MatcherInterface<T> {
public:
VariadicOperatorMatcherInterface(VariadicOperatorFunction Func,
- ArrayRef<DynTypedMatcher> InnerMatchers)
- : Func(Func), InnerMatchers(InnerMatchers) {}
+ std::vector<DynTypedMatcher> InnerMatchers)
+ : Func(Func), InnerMatchers(std::move(InnerMatchers)) {}
virtual bool matches(const T &Node, ASTMatchFinder *Finder,
BoundNodesTreeBuilder *Builder) const {
@@ -1150,7 +1150,8 @@ public:
addMatcher<T>(Param3, Matchers);
addMatcher<T>(Param4, Matchers);
addMatcher<T>(Param5, Matchers);
- return Matcher<T>(new VariadicOperatorMatcherInterface<T>(Func, Matchers));
+ return Matcher<T>(
+ new VariadicOperatorMatcherInterface<T>(Func, std::move(Matchers)));
}
private:
@@ -1246,8 +1247,8 @@ bool AnyOfVariadicOperator(const ast_typ
template <typename T>
inline Matcher<T> DynTypedMatcher::unconditionalConvertTo() const {
- return Matcher<T>(
- new VariadicOperatorMatcherInterface<T>(AllOfVariadicOperator, *this));
+ return Matcher<T>(new VariadicOperatorMatcherInterface<T>(
+ AllOfVariadicOperator, llvm::makeArrayRef(*this)));
}
/// \brief Creates a Matcher<T> that matches if all inner matchers match.
@@ -1259,7 +1260,7 @@ BindableMatcher<T> makeAllOfComposite(
DynMatchers.push_back(*InnerMatchers[i]);
}
return BindableMatcher<T>(new VariadicOperatorMatcherInterface<T>(
- AllOfVariadicOperator, DynMatchers));
+ AllOfVariadicOperator, std::move(DynMatchers)));
}
/// \brief Creates a Matcher<T> that matches if
Modified: cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h?rev=203477&r1=203476&r2=203477&view=diff
==============================================================================
--- cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h Mon Mar 10 12:55:02 2014
@@ -78,14 +78,14 @@ public:
/// \brief Clones the provided matchers.
///
/// They should be the result of a polymorphic matcher.
- static VariantMatcher PolymorphicMatcher(ArrayRef<DynTypedMatcher> Matchers);
+ static VariantMatcher PolymorphicMatcher(std::vector<DynTypedMatcher> Matchers);
/// \brief Creates a 'variadic' operator matcher.
///
/// It will bind to the appropriate type on getTypedMatcher<T>().
static VariantMatcher VariadicOperatorMatcher(
ast_matchers::internal::VariadicOperatorFunction Func,
- ArrayRef<VariantMatcher> Args);
+ std::vector<VariantMatcher> Args);
/// \brief Makes the matcher the "null" matcher.
void reset();
Modified: cfe/trunk/include/clang/Tooling/CompilationDatabase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/CompilationDatabase.h?rev=203477&r1=203476&r2=203477&view=diff
==============================================================================
--- cfe/trunk/include/clang/Tooling/CompilationDatabase.h (original)
+++ cfe/trunk/include/clang/Tooling/CompilationDatabase.h Mon Mar 10 12:55:02 2014
@@ -42,8 +42,8 @@ namespace tooling {
/// \brief Specifies the working directory and command of a compilation.
struct CompileCommand {
CompileCommand() {}
- CompileCommand(Twine Directory, ArrayRef<std::string> CommandLine)
- : Directory(Directory.str()), CommandLine(CommandLine) {}
+ CompileCommand(Twine Directory, std::vector<std::string> CommandLine)
+ : Directory(Directory.str()), CommandLine(std::move(CommandLine)) {}
/// \brief The working directory the command was executed from.
std::string Directory;
Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Marshallers.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Marshallers.h?rev=203477&r1=203476&r2=203477&view=diff
==============================================================================
--- cfe/trunk/lib/ASTMatchers/Dynamic/Marshallers.h (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Marshallers.h Mon Mar 10 12:55:02 2014
@@ -260,7 +260,7 @@ static VariantMatcher outvalueToVariantM
NULL) {
std::vector<DynTypedMatcher> Matchers;
mergePolyMatchers(PolyMatcher, Matchers, typename T::ReturnTypes());
- VariantMatcher Out = VariantMatcher::PolymorphicMatcher(Matchers);
+ VariantMatcher Out = VariantMatcher::PolymorphicMatcher(std::move(Matchers));
return Out;
}
@@ -609,7 +609,7 @@ public:
}
InnerArgs.push_back(Value.getMatcher());
}
- return VariantMatcher::VariadicOperatorMatcher(Func, InnerArgs);
+ return VariantMatcher::VariadicOperatorMatcher(Func, std::move(InnerArgs));
}
bool isVariadic() const { return true; }
Modified: cfe/trunk/lib/ASTMatchers/Dynamic/VariantValue.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/VariantValue.cpp?rev=203477&r1=203476&r2=203477&view=diff
==============================================================================
--- cfe/trunk/lib/ASTMatchers/Dynamic/VariantValue.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/VariantValue.cpp Mon Mar 10 12:55:02 2014
@@ -48,8 +48,8 @@ private:
class VariantMatcher::PolymorphicPayload : public VariantMatcher::Payload {
public:
- PolymorphicPayload(ArrayRef<DynTypedMatcher> MatchersIn)
- : Matchers(MatchersIn) {}
+ PolymorphicPayload(std::vector<DynTypedMatcher> MatchersIn)
+ : Matchers(std::move(MatchersIn)) {}
virtual ~PolymorphicPayload() {}
@@ -98,8 +98,8 @@ public:
class VariantMatcher::VariadicOpPayload : public VariantMatcher::Payload {
public:
VariadicOpPayload(ast_matchers::internal::VariadicOperatorFunction Func,
- ArrayRef<VariantMatcher> Args)
- : Func(Func), Args(Args) {}
+ std::vector<VariantMatcher> Args)
+ : Func(Func), Args(std::move(Args)) {}
virtual llvm::Optional<DynTypedMatcher> getSingleMatcher() const {
return llvm::Optional<DynTypedMatcher>();
@@ -131,14 +131,14 @@ VariantMatcher VariantMatcher::SingleMat
}
VariantMatcher
-VariantMatcher::PolymorphicMatcher(ArrayRef<DynTypedMatcher> Matchers) {
- return VariantMatcher(new PolymorphicPayload(Matchers));
+VariantMatcher::PolymorphicMatcher(std::vector<DynTypedMatcher> Matchers) {
+ return VariantMatcher(new PolymorphicPayload(std::move(Matchers)));
}
VariantMatcher VariantMatcher::VariadicOperatorMatcher(
ast_matchers::internal::VariadicOperatorFunction Func,
- ArrayRef<VariantMatcher> Args) {
- return VariantMatcher(new VariadicOpPayload(Func, Args));
+ std::vector<VariantMatcher> Args) {
+ return VariantMatcher(new VariadicOpPayload(Func, std::move(Args)));
}
llvm::Optional<DynTypedMatcher> VariantMatcher::getSingleMatcher() const {
Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=203477&r1=203476&r2=203477&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Mon Mar 10 12:55:02 2014
@@ -253,13 +253,9 @@ class DirectoryEntry : public Entry {
public:
virtual ~DirectoryEntry();
-#if LLVM_HAS_RVALUE_REFERENCES
DirectoryEntry(StringRef Name, std::vector<Entry *> Contents, Status S)
: Entry(EK_Directory, Name), Contents(std::move(Contents)),
S(std::move(S)) {}
-#endif
- DirectoryEntry(StringRef Name, ArrayRef<Entry *> Contents, const Status &S)
- : Entry(EK_Directory, Name), Contents(Contents), S(S) {}
Status getStatus() { return S; }
typedef std::vector<Entry *>::iterator iterator;
iterator contents_begin() { return Contents.begin(); }
@@ -612,7 +608,7 @@ class VFSFromYAMLParser {
for (sys::path::reverse_iterator I = sys::path::rbegin(Parent),
E = sys::path::rend(Parent);
I != E; ++I) {
- Result = new DirectoryEntry(*I, Result,
+ Result = new DirectoryEntry(*I, llvm::makeArrayRef(Result),
Status("", "", getNextVirtualUniqueID(), sys::TimeValue::now(), 0, 0,
0, file_type::directory_file, sys::fs::all_all));
}
Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp?rev=203477&r1=203476&r2=203477&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp Mon Mar 10 12:55:02 2014
@@ -3399,10 +3399,8 @@ void BugReporter::FlushReport(BugReportE
SmallVector<BugReport*, 10> bugReports;
BugReport *exampleReport = FindReportInEquivalenceClass(EQ, bugReports);
if (exampleReport) {
- const PathDiagnosticConsumers &C = getPathDiagnosticConsumers();
- for (PathDiagnosticConsumers::const_iterator I=C.begin(),
- E=C.end(); I != E; ++I) {
- FlushReport(exampleReport, **I, bugReports);
+ for (PathDiagnosticConsumer *PDC : getPathDiagnosticConsumers()) {
+ FlushReport(exampleReport, *PDC, bugReports);
}
}
}
Modified: cfe/trunk/lib/Tooling/CompilationDatabase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/CompilationDatabase.cpp?rev=203477&r1=203476&r2=203477&view=diff
==============================================================================
--- cfe/trunk/lib/Tooling/CompilationDatabase.cpp (original)
+++ cfe/trunk/lib/Tooling/CompilationDatabase.cpp Mon Mar 10 12:55:02 2014
@@ -303,7 +303,8 @@ FixedCompilationDatabase(Twine Directory
std::vector<std::string> ToolCommandLine(1, "clang-tool");
ToolCommandLine.insert(ToolCommandLine.end(),
CommandLine.begin(), CommandLine.end());
- CompileCommands.push_back(CompileCommand(Directory, ToolCommandLine));
+ CompileCommands.push_back(
+ CompileCommand(Directory, std::move(ToolCommandLine)));
}
std::vector<CompileCommand>
More information about the cfe-commits
mailing list