summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2014-03-10 17:55:02 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2014-03-10 17:55:02 +0000
commit3f755aa7a8e74920c65e4805e35824b03ca2945d (patch)
treecb6ae73e131101a22b0a059fbc87800d4237e8d0
parente655754d572f8c7ad995acd29075f5c10594476c (diff)
downloadbcm5719-llvm-3f755aa7a8e74920c65e4805e35824b03ca2945d.tar.gz
bcm5719-llvm-3f755aa7a8e74920c65e4805e35824b03ca2945d.zip
[C++11] Avoid implicit conversion of ArrayRef to std::vector and use move semantics where appropriate.
llvm-svn: 203477
-rw-r--r--clang/include/clang/ASTMatchers/ASTMatchersInternal.h13
-rw-r--r--clang/include/clang/ASTMatchers/Dynamic/VariantValue.h4
-rw-r--r--clang/include/clang/Tooling/CompilationDatabase.h4
-rw-r--r--clang/lib/ASTMatchers/Dynamic/Marshallers.h4
-rw-r--r--clang/lib/ASTMatchers/Dynamic/VariantValue.cpp16
-rw-r--r--clang/lib/Basic/VirtualFileSystem.cpp6
-rw-r--r--clang/lib/StaticAnalyzer/Core/BugReporter.cpp6
-rw-r--r--clang/lib/Tooling/CompilationDatabase.cpp3
8 files changed, 26 insertions, 30 deletions
diff --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
index dff7fd7aa50..45c5d7ae6e1 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -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_type_traits::DynTypedNode DynNode,
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
diff --git a/clang/include/clang/ASTMatchers/Dynamic/VariantValue.h b/clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
index 1a69a641278..c6853572ec8 100644
--- a/clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
+++ b/clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
@@ -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();
diff --git a/clang/include/clang/Tooling/CompilationDatabase.h b/clang/include/clang/Tooling/CompilationDatabase.h
index 33a9eea0fb3..3edd0d164b9 100644
--- a/clang/include/clang/Tooling/CompilationDatabase.h
+++ b/clang/include/clang/Tooling/CompilationDatabase.h
@@ -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;
diff --git a/clang/lib/ASTMatchers/Dynamic/Marshallers.h b/clang/lib/ASTMatchers/Dynamic/Marshallers.h
index d2259c4e939..77268076f02 100644
--- a/clang/lib/ASTMatchers/Dynamic/Marshallers.h
+++ b/clang/lib/ASTMatchers/Dynamic/Marshallers.h
@@ -260,7 +260,7 @@ static VariantMatcher outvalueToVariantMatcher(const T &PolyMatcher,
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; }
diff --git a/clang/lib/ASTMatchers/Dynamic/VariantValue.cpp b/clang/lib/ASTMatchers/Dynamic/VariantValue.cpp
index 70d37ca399a..9c7262e34fd 100644
--- a/clang/lib/ASTMatchers/Dynamic/VariantValue.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/VariantValue.cpp
@@ -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::SingleMatcher(const DynTypedMatcher &Matcher) {
}
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 {
diff --git a/clang/lib/Basic/VirtualFileSystem.cpp b/clang/lib/Basic/VirtualFileSystem.cpp
index bfc2db73e88..9a88cfd3897 100644
--- a/clang/lib/Basic/VirtualFileSystem.cpp
+++ b/clang/lib/Basic/VirtualFileSystem.cpp
@@ -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));
}
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
index db684883af2..1b55cdec589 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -3399,10 +3399,8 @@ void BugReporter::FlushReport(BugReportEquivClass& EQ) {
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);
}
}
}
diff --git a/clang/lib/Tooling/CompilationDatabase.cpp b/clang/lib/Tooling/CompilationDatabase.cpp
index 57424e37e93..b513446a543 100644
--- a/clang/lib/Tooling/CompilationDatabase.cpp
+++ b/clang/lib/Tooling/CompilationDatabase.cpp
@@ -303,7 +303,8 @@ FixedCompilationDatabase(Twine Directory, ArrayRef<std::string> CommandLine) {
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>
OpenPOWER on IntegriCloud