Convert Pass()→std::move() in //tools
❆(੭ु ◜◡‾)੭ु⁾☃❆
BUG=557422
R=avi@chromium.org
TBR=brettw@chromium.org,rdevlin.cronin@chromium.org
Review URL: https://codereview.chromium.org/1544333002
Cr-Original-Commit-Position: refs/heads/master@{#366943}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 424dfa526b76b06bb364a773fbaa6d19fb36d0ce
diff --git a/tools/gn/build_settings.cc b/tools/gn/build_settings.cc
index 63ff358..72a74c3 100644
--- a/tools/gn/build_settings.cc
+++ b/tools/gn/build_settings.cc
@@ -4,6 +4,8 @@
#include "tools/gn/build_settings.h"
+#include <utility>
+
#include "base/files/file_util.h"
#include "tools/gn/filesystem_utils.h"
@@ -60,5 +62,5 @@
void BuildSettings::ItemDefined(scoped_ptr<Item> item) const {
DCHECK(item);
if (!item_defined_callback_.is_null())
- item_defined_callback_.Run(item.Pass());
+ item_defined_callback_.Run(std::move(item));
}
diff --git a/tools/gn/build_settings.h b/tools/gn/build_settings.h
index 71d0fb9..8fe2ce9 100644
--- a/tools/gn/build_settings.h
+++ b/tools/gn/build_settings.h
@@ -7,6 +7,7 @@
#include <map>
#include <set>
+#include <utility>
#include "base/callback.h"
#include "base/files/file_path.h"
@@ -91,7 +92,7 @@
return exec_script_whitelist_.get();
}
void set_exec_script_whitelist(scoped_ptr<std::set<SourceFile>> list) {
- exec_script_whitelist_ = list.Pass();
+ exec_script_whitelist_ = std::move(list);
}
// When set (the default), code should perform normal validation of inputs
diff --git a/tools/gn/builder.cc b/tools/gn/builder.cc
index 5af7c3d..a05493b 100644
--- a/tools/gn/builder.cc
+++ b/tools/gn/builder.cc
@@ -5,6 +5,7 @@
#include "tools/gn/builder.h"
#include <stddef.h>
+#include <utility>
#include "tools/gn/config.h"
#include "tools/gn/deps_iterator.h"
@@ -82,7 +83,7 @@
return;
}
- record->set_item(item.Pass());
+ record->set_item(std::move(item));
// Do target-specific dependency setup. This will also schedule dependency
// loads for targets that are required.
diff --git a/tools/gn/builder_record.h b/tools/gn/builder_record.h
index 0940cc8..469b1cf 100644
--- a/tools/gn/builder_record.h
+++ b/tools/gn/builder_record.h
@@ -6,6 +6,7 @@
#define TOOLS_GN_BUILDER_RECORD_H_
#include <set>
+#include <utility>
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
@@ -54,7 +55,7 @@
Item* item() { return item_.get(); }
const Item* item() const { return item_.get(); }
- void set_item(scoped_ptr<Item> item) { item_ = item.Pass(); }
+ void set_item(scoped_ptr<Item> item) { item_ = std::move(item); }
// Indicates from where this item was originally referenced from that caused
// it to be loaded. For targets for which we encountered the declaration
diff --git a/tools/gn/function_toolchain.cc b/tools/gn/function_toolchain.cc
index ed4bbc3..5853255 100644
--- a/tools/gn/function_toolchain.cc
+++ b/tools/gn/function_toolchain.cc
@@ -4,6 +4,7 @@
#include <algorithm>
#include <limits>
+#include <utility>
#include "tools/gn/err.h"
#include "tools/gn/functions.h"
@@ -892,7 +893,7 @@
if (!block_scope.CheckForUnusedVars(err))
return Value();
- toolchain->SetTool(tool_type, tool.Pass());
+ toolchain->SetTool(tool_type, std::move(tool));
return Value();
}
diff --git a/tools/gn/functions.cc b/tools/gn/functions.cc
index d3d5d25..fb02fa8 100644
--- a/tools/gn/functions.cc
+++ b/tools/gn/functions.cc
@@ -5,8 +5,8 @@
#include "tools/gn/functions.h"
#include <stddef.h>
-
#include <iostream>
+#include <utility>
#include "base/environment.h"
#include "base/strings/string_util.h"
@@ -673,7 +673,7 @@
scoped_ptr<PatternList> f(new PatternList);
f->SetFromValue(args[0], err);
if (!err->has_error())
- scope->set_sources_assignment_filter(f.Pass());
+ scope->set_sources_assignment_filter(std::move(f));
}
return Value();
}
diff --git a/tools/gn/functions_unittest.cc b/tools/gn/functions_unittest.cc
index 6a6c679..e2f6756 100644
--- a/tools/gn/functions_unittest.cc
+++ b/tools/gn/functions_unittest.cc
@@ -2,8 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "testing/gtest/include/gtest/gtest.h"
#include "tools/gn/functions.h"
+
+#include <utility>
+
+#include "testing/gtest/include/gtest/gtest.h"
#include "tools/gn/parse_tree.h"
#include "tools/gn/test_with_scope.h"
#include "tools/gn/value.h"
@@ -47,7 +50,7 @@
undef_accessor->set_member(scoped_ptr<IdentifierNode>(
new IdentifierNode(undefined_token)));
ListNode args_list_accessor_defined;
- args_list_accessor_defined.append_item(undef_accessor.Pass());
+ args_list_accessor_defined.append_item(std::move(undef_accessor));
result = functions::RunDefined(setup.scope(), &function_call,
&args_list_accessor_defined, &err);
ASSERT_EQ(Value::BOOLEAN, result.type());
diff --git a/tools/gn/input_conversion.cc b/tools/gn/input_conversion.cc
index cca23e1..b43ee12 100644
--- a/tools/gn/input_conversion.cc
+++ b/tools/gn/input_conversion.cc
@@ -4,6 +4,8 @@
#include "tools/gn/input_conversion.h"
+#include <utility>
+
#include "base/macros.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
@@ -81,7 +83,7 @@
// we made, rather than the result of running the block (which will be empty).
if (what == PARSE_SCOPE) {
DCHECK(result.type() == Value::NONE);
- result = Value(origin, scope.Pass());
+ result = Value(origin, std::move(scope));
}
return result;
}
diff --git a/tools/gn/input_file_manager.cc b/tools/gn/input_file_manager.cc
index b90a9f1..de84101 100644
--- a/tools/gn/input_file_manager.cc
+++ b/tools/gn/input_file_manager.cc
@@ -4,6 +4,8 @@
#include "tools/gn/input_file_manager.h"
+#include <utility>
+
#include "base/bind.h"
#include "base/stl_util.h"
#include "tools/gn/filesystem_utils.h"
@@ -287,7 +289,7 @@
data->loaded = true;
if (success) {
data->tokens.swap(tokens);
- data->parsed_root = root.Pass();
+ data->parsed_root = std::move(root);
} else {
data->parse_error = *err;
}
diff --git a/tools/gn/loader_unittest.cc b/tools/gn/loader_unittest.cc
index 914e475..6496eaa 100644
--- a/tools/gn/loader_unittest.cc
+++ b/tools/gn/loader_unittest.cc
@@ -78,7 +78,7 @@
EXPECT_FALSE(err.has_error());
// Parse.
- canned->root = Parser::Parse(canned->tokens, &err).Pass();
+ canned->root = Parser::Parse(canned->tokens, &err);
EXPECT_FALSE(err.has_error());
canned_responses_[source_file] = std::move(canned);
diff --git a/tools/gn/ninja_binary_target_writer_unittest.cc b/tools/gn/ninja_binary_target_writer_unittest.cc
index b9c50b7..dc9c8dd 100644
--- a/tools/gn/ninja_binary_target_writer_unittest.cc
+++ b/tools/gn/ninja_binary_target_writer_unittest.cc
@@ -2,10 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "tools/gn/ninja_binary_target_writer.h"
+
#include <sstream>
+#include <utility>
#include "testing/gtest/include/gtest/gtest.h"
-#include "tools/gn/ninja_binary_target_writer.h"
#include "tools/gn/scheduler.h"
#include "tools/gn/target.h"
#include "tools/gn/test_with_scope.h"
@@ -485,7 +487,7 @@
cxx_tool->set_outputs(SubstitutionList::MakeForTest(
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o"));
cxx_tool->set_precompiled_header_type(Tool::PCH_MSVC);
- pch_toolchain.SetTool(Toolchain::TYPE_CXX, cxx_tool.Pass());
+ pch_toolchain.SetTool(Toolchain::TYPE_CXX, std::move(cxx_tool));
// Add a C compiler as well.
scoped_ptr<Tool> cc_tool(new Tool);
@@ -496,7 +498,7 @@
cc_tool->set_outputs(SubstitutionList::MakeForTest(
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o"));
cc_tool->set_precompiled_header_type(Tool::PCH_MSVC);
- pch_toolchain.SetTool(Toolchain::TYPE_CC, cc_tool.Pass());
+ pch_toolchain.SetTool(Toolchain::TYPE_CC, std::move(cc_tool));
pch_toolchain.ToolchainSetupComplete();
// This target doesn't specify precompiled headers.
@@ -613,7 +615,7 @@
cxx_tool->set_outputs(SubstitutionList::MakeForTest(
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o"));
cxx_tool->set_precompiled_header_type(Tool::PCH_GCC);
- pch_toolchain.SetTool(Toolchain::TYPE_CXX, cxx_tool.Pass());
+ pch_toolchain.SetTool(Toolchain::TYPE_CXX, std::move(cxx_tool));
pch_toolchain.ToolchainSetupComplete();
// Add a C compiler as well.
@@ -625,7 +627,7 @@
cc_tool->set_outputs(SubstitutionList::MakeForTest(
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o"));
cc_tool->set_precompiled_header_type(Tool::PCH_GCC);
- pch_toolchain.SetTool(Toolchain::TYPE_CC, cc_tool.Pass());
+ pch_toolchain.SetTool(Toolchain::TYPE_CC, std::move(cc_tool));
pch_toolchain.ToolchainSetupComplete();
// This target doesn't specify precompiled headers.
diff --git a/tools/gn/operators_unittest.cc b/tools/gn/operators_unittest.cc
index 20e344f..0e7308d 100644
--- a/tools/gn/operators_unittest.cc
+++ b/tools/gn/operators_unittest.cc
@@ -2,10 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "tools/gn/operators.h"
+
#include <stdint.h>
+#include <utility>
#include "testing/gtest/include/gtest/gtest.h"
-#include "tools/gn/operators.h"
#include "tools/gn/parse_tree.h"
#include "tools/gn/pattern.h"
#include "tools/gn/test_with_scope.h"
@@ -30,7 +32,7 @@
scoped_ptr<ListNode> ListWithLiteral(const Token& token) {
scoped_ptr<ListNode> list(new ListNode);
list->append_item(scoped_ptr<ParseNode>(new LiteralNode(token)));
- return list.Pass();
+ return list;
}
} // namespace
@@ -56,7 +58,7 @@
// Set up the filter on the scope to remove everything ending with "rm"
scoped_ptr<PatternList> pattern_list(new PatternList);
pattern_list->Append(Pattern("*rm"));
- setup.scope()->set_sources_assignment_filter(pattern_list.Pass());
+ setup.scope()->set_sources_assignment_filter(std::move(pattern_list));
// Append an integer.
const char integer_value[] = "5";
@@ -121,7 +123,7 @@
const char twelve_str[] = "12";
Token twelve(Location(), Token::INTEGER, twelve_str);
outer_list->append_item(ListWithLiteral(twelve));
- node.set_right(outer_list.Pass());
+ node.set_right(std::move(outer_list));
Value ret = ExecuteBinaryOperator(setup.scope(), &node, node.left(),
node.right(), &err);
diff --git a/tools/gn/parse_tree.h b/tools/gn/parse_tree.h
index 3e6f87a..6693bbd 100644
--- a/tools/gn/parse_tree.h
+++ b/tools/gn/parse_tree.h
@@ -6,7 +6,7 @@
#define TOOLS_GN_PARSE_TREE_H_
#include <stddef.h>
-
+#include <utility>
#include <vector>
#include "base/macros.h"
@@ -150,12 +150,12 @@
// Index is the expression inside the []. Will be null if member is set.
const ParseNode* index() const { return index_.get(); }
- void set_index(scoped_ptr<ParseNode> i) { index_ = i.Pass(); }
+ void set_index(scoped_ptr<ParseNode> i) { index_ = std::move(i); }
// The member is the identifier on the right hand side of the dot. Will be
// null if the index is set.
const IdentifierNode* member() const { return member_.get(); }
- void set_member(scoped_ptr<IdentifierNode> i) { member_ = i.Pass(); }
+ void set_member(scoped_ptr<IdentifierNode> i) { member_ = std::move(i); }
void SetNewLocation(int line_number);
@@ -192,14 +192,10 @@
void set_op(const Token& t) { op_ = t; }
const ParseNode* left() const { return left_.get(); }
- void set_left(scoped_ptr<ParseNode> left) {
- left_ = left.Pass();
- }
+ void set_left(scoped_ptr<ParseNode> left) { left_ = std::move(left); }
const ParseNode* right() const { return right_.get(); }
- void set_right(scoped_ptr<ParseNode> right) {
- right_ = right.Pass();
- }
+ void set_right(scoped_ptr<ParseNode> right) { right_ = std::move(right); }
private:
scoped_ptr<ParseNode> left_;
@@ -225,7 +221,7 @@
void Print(std::ostream& out, int indent) const override;
void set_begin_token(const Token& t) { begin_token_ = t; }
- void set_end(scoped_ptr<EndNode> e) { end_ = e.Pass(); }
+ void set_end(scoped_ptr<EndNode> e) { end_ = std::move(e); }
const EndNode* End() const { return end_.get(); }
const std::vector<ParseNode*>& statements() const { return statements_; }
@@ -263,21 +259,15 @@
void set_if_token(const Token& token) { if_token_ = token; }
const ParseNode* condition() const { return condition_.get(); }
- void set_condition(scoped_ptr<ParseNode> c) {
- condition_ = c.Pass();
- }
+ void set_condition(scoped_ptr<ParseNode> c) { condition_ = std::move(c); }
const BlockNode* if_true() const { return if_true_.get(); }
- void set_if_true(scoped_ptr<BlockNode> t) {
- if_true_ = t.Pass();
- }
+ void set_if_true(scoped_ptr<BlockNode> t) { if_true_ = std::move(t); }
// This is either empty, a block (for the else clause), or another
// condition.
const ParseNode* if_false() const { return if_false_.get(); }
- void set_if_false(scoped_ptr<ParseNode> f) {
- if_false_ = f.Pass();
- }
+ void set_if_false(scoped_ptr<ParseNode> f) { if_false_ = std::move(f); }
private:
// Token corresponding to the "if" string.
@@ -309,10 +299,10 @@
void set_function(Token t) { function_ = t; }
const ListNode* args() const { return args_.get(); }
- void set_args(scoped_ptr<ListNode> a) { args_ = a.Pass(); }
+ void set_args(scoped_ptr<ListNode> a) { args_ = std::move(a); }
const BlockNode* block() const { return block_.get(); }
- void set_block(scoped_ptr<BlockNode> b) { block_ = b.Pass(); }
+ void set_block(scoped_ptr<BlockNode> b) { block_ = std::move(b); }
private:
Token function_;
@@ -365,7 +355,7 @@
void Print(std::ostream& out, int indent) const override;
void set_begin_token(const Token& t) { begin_token_ = t; }
- void set_end(scoped_ptr<EndNode> e) { end_ = e.Pass(); }
+ void set_end(scoped_ptr<EndNode> e) { end_ = std::move(e); }
const EndNode* End() const { return end_.get(); }
void append_item(scoped_ptr<ParseNode> s) {
@@ -455,7 +445,7 @@
const ParseNode* operand() const { return operand_.get(); }
void set_operand(scoped_ptr<ParseNode> operand) {
- operand_ = operand.Pass();
+ operand_ = std::move(operand);
}
private:
diff --git a/tools/gn/parse_tree_unittest.cc b/tools/gn/parse_tree_unittest.cc
index bf6c716..b46114f 100644
--- a/tools/gn/parse_tree_unittest.cc
+++ b/tools/gn/parse_tree_unittest.cc
@@ -2,11 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "tools/gn/parse_tree.h"
+
#include <stdint.h>
+#include <utility>
#include "testing/gtest/include/gtest/gtest.h"
#include "tools/gn/input_file.h"
-#include "tools/gn/parse_tree.h"
#include "tools/gn/scope.h"
#include "tools/gn/test_with_scope.h"
@@ -24,7 +26,7 @@
scoped_ptr<IdentifierNode> member_identifier(
new IdentifierNode(member_token));
- accessor.set_member(member_identifier.Pass());
+ accessor.set_member(std::move(member_identifier));
// The access should fail because a is not defined.
Err err;
diff --git a/tools/gn/parser.cc b/tools/gn/parser.cc
index b2e22fb..79966b8 100644
--- a/tools/gn/parser.cc
+++ b/tools/gn/parser.cc
@@ -4,6 +4,8 @@
#include "tools/gn/parser.h"
+#include <utility>
+
#include "base/logging.h"
#include "tools/gn/functions.h"
#include "tools/gn/operators.h"
@@ -215,7 +217,7 @@
*err = Err(p.cur_token(), "Trailing garbage");
return nullptr;
}
- return expr.Pass();
+ return expr;
}
// static
@@ -328,7 +330,7 @@
scoped_ptr<ParseNode> left = (this->*prefix)(token);
if (has_error())
- return left.Pass();
+ return left;
while (!at_end() && !IsStatementBreak(cur_token().type()) &&
precedence <= expressions_[cur_token().type()].precedence) {
@@ -340,12 +342,12 @@
token.value().as_string() + std::string("'"));
return scoped_ptr<ParseNode>();
}
- left = (this->*infix)(left.Pass(), token);
+ left = (this->*infix)(std::move(left), token);
if (has_error())
return scoped_ptr<ParseNode>();
}
- return left.Pass();
+ return left;
}
scoped_ptr<ParseNode> Parser::Literal(Token token) {
@@ -353,13 +355,13 @@
}
scoped_ptr<ParseNode> Parser::Name(Token token) {
- return IdentifierOrCall(scoped_ptr<ParseNode>(), token).Pass();
+ return IdentifierOrCall(scoped_ptr<ParseNode>(), token);
}
scoped_ptr<ParseNode> Parser::BlockComment(Token token) {
scoped_ptr<BlockCommentNode> comment(new BlockCommentNode());
comment->set_comment(token);
- return comment.Pass();
+ return std::move(comment);
}
scoped_ptr<ParseNode> Parser::Group(Token token) {
@@ -367,7 +369,7 @@
if (has_error())
return scoped_ptr<ParseNode>();
Consume(Token::RIGHT_PAREN, "Expected ')'");
- return expr.Pass();
+ return expr;
}
scoped_ptr<ParseNode> Parser::Not(Token token) {
@@ -381,15 +383,15 @@
}
scoped_ptr<UnaryOpNode> unary_op(new UnaryOpNode);
unary_op->set_op(token);
- unary_op->set_operand(expr.Pass());
- return unary_op.Pass();
+ unary_op->set_operand(std::move(expr));
+ return std::move(unary_op);
}
scoped_ptr<ParseNode> Parser::List(Token node) {
scoped_ptr<ParseNode> list(ParseList(node, Token::RIGHT_BRACKET, true));
if (!has_error() && !at_end())
Consume(Token::RIGHT_BRACKET, "Expected ']'");
- return list.Pass();
+ return list;
}
scoped_ptr<ParseNode> Parser::BinaryOperator(scoped_ptr<ParseNode> left,
@@ -405,9 +407,9 @@
}
scoped_ptr<BinaryOpNode> binary_op(new BinaryOpNode);
binary_op->set_op(token);
- binary_op->set_left(left.Pass());
- binary_op->set_right(right.Pass());
- return binary_op.Pass();
+ binary_op->set_left(std::move(left));
+ binary_op->set_right(std::move(right));
+ return std::move(binary_op);
}
scoped_ptr<ParseNode> Parser::IdentifierOrCall(scoped_ptr<ParseNode> left,
@@ -439,14 +441,14 @@
if (!left && !has_arg) {
// Not a function call, just a standalone identifier.
- return scoped_ptr<ParseNode>(new IdentifierNode(token)).Pass();
+ return scoped_ptr<ParseNode>(new IdentifierNode(token));
}
scoped_ptr<FunctionCallNode> func_call(new FunctionCallNode);
func_call->set_function(token);
- func_call->set_args(list.Pass());
+ func_call->set_args(std::move(list));
if (block)
- func_call->set_block(block.Pass());
- return func_call.Pass();
+ func_call->set_block(std::move(block));
+ return std::move(func_call);
}
scoped_ptr<ParseNode> Parser::Assignment(scoped_ptr<ParseNode> left,
@@ -463,9 +465,9 @@
}
scoped_ptr<BinaryOpNode> assign(new BinaryOpNode);
assign->set_op(token);
- assign->set_left(left.Pass());
- assign->set_right(value.Pass());
- return assign.Pass();
+ assign->set_left(std::move(left));
+ assign->set_right(std::move(value));
+ return std::move(assign);
}
scoped_ptr<ParseNode> Parser::Subscript(scoped_ptr<ParseNode> left,
@@ -483,8 +485,8 @@
Consume(Token::RIGHT_BRACKET, "Expecting ']' after subscript.");
scoped_ptr<AccessorNode> accessor(new AccessorNode);
accessor->set_base(left->AsIdentifier()->value());
- accessor->set_index(value.Pass());
- return accessor.Pass();
+ accessor->set_index(std::move(value));
+ return std::move(accessor);
}
scoped_ptr<ParseNode> Parser::DotOperator(scoped_ptr<ParseNode> left,
@@ -508,7 +510,7 @@
accessor->set_base(left->AsIdentifier()->value());
accessor->set_member(scoped_ptr<IdentifierNode>(
static_cast<IdentifierNode*>(right.release())));
- return accessor.Pass();
+ return std::move(accessor);
}
// Does not Consume the start or end token.
@@ -553,7 +555,7 @@
return scoped_ptr<ListNode>();
}
list->set_end(make_scoped_ptr(new EndNode(cur_token())));
- return list.Pass();
+ return list;
}
scoped_ptr<ParseNode> Parser::ParseFile() {
@@ -564,7 +566,7 @@
scoped_ptr<ParseNode> statement = ParseStatement();
if (!statement)
break;
- file->append_statement(statement.Pass());
+ file->append_statement(std::move(statement));
}
if (!at_end() && !has_error())
*err_ = Err(cur_token(), "Unexpected here, should be newline.");
@@ -577,7 +579,7 @@
// ignorant of them.
AssignComments(file.get());
- return file.Pass();
+ return std::move(file);
}
scoped_ptr<ParseNode> Parser::ParseStatement() {
@@ -591,7 +593,7 @@
scoped_ptr<ParseNode> stmt = ParseExpression();
if (stmt) {
if (stmt->AsFunctionCall() || IsAssignment(stmt.get()))
- return stmt.Pass();
+ return stmt;
}
if (!has_error()) {
Token token = at_end() ? tokens_[tokens_.size() - 1] : cur_token();
@@ -618,9 +620,9 @@
scoped_ptr<ParseNode> statement = ParseStatement();
if (!statement)
return scoped_ptr<BlockNode>();
- block->append_statement(statement.Pass());
+ block->append_statement(std::move(statement));
}
- return block.Pass();
+ return block;
}
scoped_ptr<ParseNode> Parser::ParseCondition() {
@@ -631,12 +633,12 @@
if (IsAssignment(condition->condition()))
*err_ = Err(condition->condition(), "Assignment not allowed in 'if'.");
Consume(Token::RIGHT_PAREN, "Expected ')' after condition of 'if'.");
- condition->set_if_true(ParseBlock().Pass());
+ condition->set_if_true(ParseBlock());
if (Match(Token::ELSE)) {
if (LookAhead(Token::LEFT_BRACE)) {
- condition->set_if_false(ParseBlock().Pass());
+ condition->set_if_false(ParseBlock());
} else if (LookAhead(Token::IF)) {
- condition->set_if_false(ParseStatement().Pass());
+ condition->set_if_false(ParseStatement());
} else {
*err_ = Err(cur_token(), "Expected '{' or 'if' after 'else'.");
return scoped_ptr<ParseNode>();
@@ -644,7 +646,7 @@
}
if (has_error())
return scoped_ptr<ParseNode>();
- return condition.Pass();
+ return std::move(condition);
}
void Parser::TraverseOrder(const ParseNode* root,
diff --git a/tools/gn/scope.cc b/tools/gn/scope.cc
index 37ddbdd..2bf9dd4 100644
--- a/tools/gn/scope.cc
+++ b/tools/gn/scope.cc
@@ -377,7 +377,7 @@
NonRecursiveMergeTo(result.get(), options, nullptr, "<SHOULDN'T HAPPEN>",
&err);
DCHECK(!err.has_error());
- return result.Pass();
+ return result;
}
Scope* Scope::MakeTargetDefaults(const std::string& target_type) {
diff --git a/tools/gn/scope.h b/tools/gn/scope.h
index 0b9bfbe..7b32941 100644
--- a/tools/gn/scope.h
+++ b/tools/gn/scope.h
@@ -7,6 +7,7 @@
#include <map>
#include <set>
+#include <utility>
#include "base/containers/hash_tables.h"
#include "base/macros.h"
@@ -240,7 +241,7 @@
const PatternList* GetSourcesAssignmentFilter() const;
void set_sources_assignment_filter(
scoped_ptr<PatternList> f) {
- sources_assignment_filter_ = f.Pass();
+ sources_assignment_filter_ = std::move(f);
}
// Indicates if we're currently processing the build configuration file.
diff --git a/tools/gn/setup.cc b/tools/gn/setup.cc
index 87339ca..774d877 100644
--- a/tools/gn/setup.cc
+++ b/tools/gn/setup.cc
@@ -5,9 +5,9 @@
#include "tools/gn/setup.h"
#include <stdlib.h>
-
#include <algorithm>
#include <sstream>
+#include <utility>
#include "base/bind.h"
#include "base/command_line.h"
@@ -652,7 +652,7 @@
return false;
}
}
- build_settings_.set_exec_script_whitelist(whitelist.Pass());
+ build_settings_.set_exec_script_whitelist(std::move(whitelist));
}
return true;
diff --git a/tools/gn/string_utils_unittest.cc b/tools/gn/string_utils_unittest.cc
index a00e824..4e18eb5 100644
--- a/tools/gn/string_utils_unittest.cc
+++ b/tools/gn/string_utils_unittest.cc
@@ -2,13 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "tools/gn/string_utils.h"
+
#include <stdint.h>
+#include <utility>
#include "testing/gtest/include/gtest/gtest.h"
#include "tools/gn/err.h"
#include "tools/gn/scope.h"
#include "tools/gn/settings.h"
-#include "tools/gn/string_utils.h"
#include "tools/gn/token.h"
#include "tools/gn/value.h"
@@ -23,7 +25,7 @@
// Nested scope called "onescope" with a value "one" inside it.
scoped_ptr<Scope> onescope(new Scope(static_cast<const Settings*>(nullptr)));
onescope->SetValue("one", Value(nullptr, one), nullptr);
- scope.SetValue("onescope", Value(nullptr, onescope.Pass()), nullptr);
+ scope.SetValue("onescope", Value(nullptr, std::move(onescope)), nullptr);
// List called "onelist" with one value that maps to 1.
Value onelist(nullptr, Value::LIST);
diff --git a/tools/gn/target_unittest.cc b/tools/gn/target_unittest.cc
index 986fa65..4d9b1da 100644
--- a/tools/gn/target_unittest.cc
+++ b/tools/gn/target_unittest.cc
@@ -2,12 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "tools/gn/target.h"
+
+#include <utility>
+
#include "testing/gtest/include/gtest/gtest.h"
#include "tools/gn/build_settings.h"
#include "tools/gn/config.h"
#include "tools/gn/scheduler.h"
#include "tools/gn/settings.h"
-#include "tools/gn/target.h"
#include "tools/gn/test_with_scope.h"
#include "tools/gn/toolchain.h"
@@ -445,7 +448,7 @@
solink_tool->set_outputs(SubstitutionList::MakeForTest(
kLinkPattern, kDependPattern));
- toolchain.SetTool(Toolchain::TYPE_SOLINK, solink_tool.Pass());
+ toolchain.SetTool(Toolchain::TYPE_SOLINK, std::move(solink_tool));
Target target(setup.settings(), Label(SourceDir("//a/"), "a"));
target.set_output_type(Target::SHARED_LIBRARY);
diff --git a/tools/gn/template.cc b/tools/gn/template.cc
index 3d58b9a..012e716 100644
--- a/tools/gn/template.cc
+++ b/tools/gn/template.cc
@@ -4,6 +4,8 @@
#include "tools/gn/template.h"
+#include <utility>
+
#include "tools/gn/err.h"
#include "tools/gn/functions.h"
#include "tools/gn/parse_tree.h"
@@ -17,9 +19,7 @@
}
Template::Template(scoped_ptr<Scope> scope, const FunctionCallNode* def)
- : closure_(scope.Pass()),
- definition_(def) {
-}
+ : closure_(std::move(scope)), definition_(def) {}
Template::~Template() {
}
@@ -81,7 +81,7 @@
template_scope.SetValue(kInvoker, Value(nullptr, scoped_ptr<Scope>()),
invocation);
Value* invoker_value = template_scope.GetMutableValue(kInvoker, false);
- invoker_value->SetScopeValue(invocation_scope.Pass());
+ invoker_value->SetScopeValue(std::move(invocation_scope));
template_scope.set_source_dir(scope->GetSourceDir());
const base::StringPiece target_name("target_name");
diff --git a/tools/gn/test_with_scope.cc b/tools/gn/test_with_scope.cc
index a6953ae..8890338 100644
--- a/tools/gn/test_with_scope.cc
+++ b/tools/gn/test_with_scope.cc
@@ -4,6 +4,8 @@
#include "tools/gn/test_with_scope.h"
+#include <utility>
+
#include "base/bind.h"
#include "tools/gn/parser.h"
#include "tools/gn/tokenizer.h"
@@ -47,7 +49,7 @@
cc_tool.get());
cc_tool->set_outputs(SubstitutionList::MakeForTest(
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o"));
- toolchain->SetTool(Toolchain::TYPE_CC, cc_tool.Pass());
+ toolchain->SetTool(Toolchain::TYPE_CC, std::move(cc_tool));
// CXX
scoped_ptr<Tool> cxx_tool(new Tool);
@@ -57,7 +59,7 @@
cxx_tool.get());
cxx_tool->set_outputs(SubstitutionList::MakeForTest(
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o"));
- toolchain->SetTool(Toolchain::TYPE_CXX, cxx_tool.Pass());
+ toolchain->SetTool(Toolchain::TYPE_CXX, std::move(cxx_tool));
// OBJC
scoped_ptr<Tool> objc_tool(new Tool);
@@ -67,7 +69,7 @@
objc_tool.get());
objc_tool->set_outputs(SubstitutionList::MakeForTest(
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o"));
- toolchain->SetTool(Toolchain::TYPE_OBJC, objc_tool.Pass());
+ toolchain->SetTool(Toolchain::TYPE_OBJC, std::move(objc_tool));
// OBJC
scoped_ptr<Tool> objcxx_tool(new Tool);
@@ -77,7 +79,7 @@
objcxx_tool.get());
objcxx_tool->set_outputs(SubstitutionList::MakeForTest(
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o"));
- toolchain->SetTool(Toolchain::TYPE_OBJCXX, objcxx_tool.Pass());
+ toolchain->SetTool(Toolchain::TYPE_OBJCXX, std::move(objcxx_tool));
// Don't use RC and ASM tools in unit tests yet. Add here if needed.
@@ -89,7 +91,7 @@
alink_tool->set_output_prefix("lib");
alink_tool->set_outputs(SubstitutionList::MakeForTest(
"{{target_out_dir}}/{{target_output_name}}.a"));
- toolchain->SetTool(Toolchain::TYPE_ALINK, alink_tool.Pass());
+ toolchain->SetTool(Toolchain::TYPE_ALINK, std::move(alink_tool));
// SOLINK
scoped_ptr<Tool> solink_tool(new Tool);
@@ -101,7 +103,7 @@
solink_tool->set_default_output_extension(".so");
solink_tool->set_outputs(SubstitutionList::MakeForTest(
"{{root_out_dir}}/{{target_output_name}}{{output_extension}}"));
- toolchain->SetTool(Toolchain::TYPE_SOLINK, solink_tool.Pass());
+ toolchain->SetTool(Toolchain::TYPE_SOLINK, std::move(solink_tool));
// SOLINK_MODULE
scoped_ptr<Tool> solink_module_tool(new Tool);
@@ -113,7 +115,8 @@
solink_module_tool->set_default_output_extension(".so");
solink_module_tool->set_outputs(SubstitutionList::MakeForTest(
"{{root_out_dir}}/{{target_output_name}}{{output_extension}}"));
- toolchain->SetTool(Toolchain::TYPE_SOLINK_MODULE, solink_module_tool.Pass());
+ toolchain->SetTool(Toolchain::TYPE_SOLINK_MODULE,
+ std::move(solink_module_tool));
// LINK
scoped_ptr<Tool> link_tool(new Tool);
@@ -123,17 +126,17 @@
link_tool->set_lib_dir_switch("-L");
link_tool->set_outputs(SubstitutionList::MakeForTest(
"{{root_out_dir}}/{{target_output_name}}"));
- toolchain->SetTool(Toolchain::TYPE_LINK, link_tool.Pass());
+ toolchain->SetTool(Toolchain::TYPE_LINK, std::move(link_tool));
// STAMP
scoped_ptr<Tool> stamp_tool(new Tool);
SetCommandForTool("touch {{output}}", stamp_tool.get());
- toolchain->SetTool(Toolchain::TYPE_STAMP, stamp_tool.Pass());
+ toolchain->SetTool(Toolchain::TYPE_STAMP, std::move(stamp_tool));
// COPY
scoped_ptr<Tool> copy_tool(new Tool);
SetCommandForTool("cp {{source}} {{output}}", copy_tool.get());
- toolchain->SetTool(Toolchain::TYPE_COPY, copy_tool.Pass());
+ toolchain->SetTool(Toolchain::TYPE_COPY, std::move(copy_tool));
toolchain->ToolchainSetupComplete();
}
diff --git a/tools/gn/toolchain.cc b/tools/gn/toolchain.cc
index 96cf166..2a70358 100644
--- a/tools/gn/toolchain.cc
+++ b/tools/gn/toolchain.cc
@@ -6,6 +6,7 @@
#include <stddef.h>
#include <string.h>
+#include <utility>
#include "base/logging.h"
#include "tools/gn/target.h"
@@ -88,7 +89,7 @@
DCHECK(type != TYPE_NONE);
DCHECK(!tools_[type].get());
t->SetComplete();
- tools_[type] = t.Pass();
+ tools_[type] = std::move(t);
}
void Toolchain::ToolchainSetupComplete() {
diff --git a/tools/gn/value.cc b/tools/gn/value.cc
index 6e8bcfa..57f23b0 100644
--- a/tools/gn/value.cc
+++ b/tools/gn/value.cc
@@ -5,6 +5,7 @@
#include "tools/gn/value.h"
#include <stddef.h>
+#include <utility>
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
@@ -60,9 +61,8 @@
string_value_(),
boolean_value_(false),
int_value_(0),
- scope_value_(scope.Pass()),
- origin_(origin) {
-}
+ scope_value_(std::move(scope)),
+ origin_(origin) {}
Value::Value(const Value& other)
: type_(other.type_),
@@ -113,7 +113,7 @@
void Value::SetScopeValue(scoped_ptr<Scope> scope) {
DCHECK(type_ == SCOPE);
- scope_value_ = scope.Pass();
+ scope_value_ = std::move(scope);
}
std::string Value::ToString(bool quote_string) const {